npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

sketch-transform

v1.0.1

Published

Transform sketch files to json and json to sketch files

Downloads

11

Readme

sketch-transform

Transform sketch files to json and json to sketch files

Usage

const { Sketch2json, readAndParseFileInSketch, sketchJsonToSketchFile } = require('./lib/index.js')
const fs = require('fs')
const fse = require('fs-extra')
// Document Meta User Page Image Preview

// Get a JSON output out of a buffer of Sketch v43+ data
Sketch2json('./sketch-examples/test.sketch', {
  single: true,
  output: `${__dirname}/dist/`
}).then(() => {
  console.error('Sketch2json 解压 sketch file 完成!!')
})


// files to sketch files
readAndParseFileInSketch('./output/')


// json to sketch files
const singleSketchJson = fse.readJsonSync('./test-json/single-sketch.json')
const preview = fse.readFile('./test-json/preview.png')
const images = [{
  '38ca6125035f10996026c761d9779f85c8d1f99e.png': fse.readFile('./test-json/38ca6125035f10996026c761d9779f85c8d1f99e.png')
}]
const output = './single.sketch'
sketchJsonToSketchFile({ sketchJson: singleSketchJson, preview, images }, output)

Sketch File format

Sketch documents are stored as ZIP archives containing JSON encoded data. The file format was originally introduced in Sketch 43 and allows for better third-party integration. Generate Sketch documents dynamically, read or modify them without opening them in Sketch.

The JSON files within the archive describe the document data and contain a number of binary assets such as bitmap images and document preview. To unarchive a document on the command line use unzip.

unzip document.sketch

Archive the contents of a document folder with zip.

zip -r -X document.sketch *

Folder structure

meta.json

Contains metadata about the document itself (a list of pages and artboards, Sketch version used to save the file, fonts used…). It’s equivalent to the output you’d get from running sketchtool metadata on the file.

document.json

Contains common data for all pages of a document, like shared styles, and a link to the JSON files in the pagesfolder.

user.json

Contains user metadata for the file, like the canvas viewport & zoom level for each page, UI metadata for the app such as panel dimensions, etc. and whether the document has been uploaded to Sketch Cloud.

pages folder

Contains a JSON file per page of the document. Each file describes the contents of a page, in a format similar to what you’d get by running sketchtool dump on the file.

images folder

The images folder contains all the bitmaps that are used in the document, at their original scales (so if the user imported a 1000x1000px image and then resized it to 200x200px, the full 1000x1000px file will be stored).

previews folder

Contains a preview image of the last page edited by the user. If the page’s size is less than 2048x2048 it will be stored at full size, otherwise it’ll be scaled to fit a 2048x2048 square.

Custom data

To store data that is not part of the Sketch document structure a special field userInfo object can be set per document and layer.

{
  "userInfo": {
    "com.example.custom.value": {
      "comment": "Looking great 👏"
    }
  }
}

You can also use the Sketch JavaScript API to set custom data. Please note that the values will be set for the current plugin or script identifier.

const settings = require('sketch/settings')

let document = require('sketch/dom').Document
settings.setDocumentSettingForKey(document, 'comment', 'Done!')

let layer = context.selection[0]
settings.setLayerSettingForKey(layer, 'comment', 'Looking great 👏')

Related resources