All Projects → xaviervia → Sketch2json

xaviervia / Sketch2json

Licence: unlicense
Get a JSON output out of a buffer of Sketch v43+ data (works both in Node and in the browser)

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Sketch2json

Xlayers
✨ Generate code from your design
Stars: ✭ 700 (+345.86%)
Mutual labels:  sketchapp
Svgo Compressor
A Plugin that compresses SVG assets using SVGO, right when you export them.
Stars: ✭ 1,068 (+580.25%)
Mutual labels:  sketchapp
Overrideit Sketchplugin
Overrideit is sketch plugin that allow designers to search in overridelist and overrides dropdowns, and with many other features.
Stars: ✭ 113 (-28.03%)
Mutual labels:  sketchapp
Sketch Commands
A collection of script commands for Sketch.app
Stars: ✭ 826 (+426.11%)
Mutual labels:  sketchapp
Sketch Foundation Kit
💎 The Foundation for Sites template for Sketch 3.
Stars: ✭ 1,011 (+543.95%)
Mutual labels:  sketchapp
Sketch Loader
Webpack loader for Sketch (+43) files
Stars: ✭ 69 (-56.05%)
Mutual labels:  sketchapp
Artboard Manager
Because moving Artboards manually is *so* 2016
Stars: ✭ 672 (+328.03%)
Mutual labels:  sketchapp
Sketch Batch Create Symbols
A plugin for Sketch to convert selected layers to individual symbols.
Stars: ✭ 134 (-14.65%)
Mutual labels:  sketchapp
Persiansupplier
Sketch Plugin for supplying dynamic persian data.
Stars: ✭ 46 (-70.7%)
Mutual labels:  sketchapp
Sketch Css Sprite Mixin
Generate a code of CSS Sprite Mixin to Clipboard in Sketch.
Stars: ✭ 105 (-33.12%)
Mutual labels:  sketchapp
Sketch Web Viewer
View and inspect Sketch 43 files in browser
Stars: ✭ 853 (+443.31%)
Mutual labels:  sketchapp
React Sketchapp Starter Kit
Initial Setup for React Sketchapp Project
Stars: ✭ 27 (-82.8%)
Mutual labels:  sketchapp
Notes
A sketch plugin for taking notes
Stars: ✭ 87 (-44.59%)
Mutual labels:  sketchapp
Sketch Map Generator
Sketch plugin to fill a shape with a map generated from a given location using Google Maps and Mapbox
Stars: ✭ 824 (+424.84%)
Mutual labels:  sketchapp
Sketch Json
Transform sketch files to json and json to sketch files
Stars: ✭ 113 (-28.03%)
Mutual labels:  sketchapp
Sketch Find And Replace
Sketch plugin to do a find and replace on text within layers
Stars: ✭ 693 (+341.4%)
Mutual labels:  sketchapp
Chart
Create the most popular types of charts by real or random data
Stars: ✭ 1,101 (+601.27%)
Mutual labels:  sketchapp
Terminal Icons
Beautiful icons for your favourite terminal apps like Hyper and iTerm2
Stars: ✭ 149 (-5.1%)
Mutual labels:  sketchapp
Data Populator
A plugin for Sketch and Adobe XD to populate your design mockups with meaningful data. Goodbye Lorem Ipsum. Hello JSON.
Stars: ✭ 1,665 (+960.51%)
Mutual labels:  sketchapp
Ishadow
Creating a beautiful iOS style shadow [Sketch Plugin]
Stars: ✭ 89 (-43.31%)
Mutual labels:  sketchapp

sketch2json

https://travis-ci.org/xaviervia/sketch2json.svg?branch=master npm version

Get a JSON output out of a buffer of Sketch v43+ data (works both in Node and in the browser)

Combined with the stylish React JSON Tree, you can inspect the Sketch file contents easily:

https://xaviervia.github.io/sketch2json

Check out the live demo in https://xaviervia.github.io/sketch2json

You can also run this from the command like with the sketchy package.

Installation

npm install --save sketch2json

Usage

In Node, you can read a Sketch file from the file system and pass it to sketch2json to get the JSON representation of it's internal data. You can use the file in tests/fixtures/simple.sketch as an example

const fs = require('fs')
const sketch2json = require('sketch2json')

fs.readFile(__dirname + '/simple.sketch', (error, data) => {
  sketch2json(data).then(result => console.log(result))
})

The result will be an object structure like:

{
  document: {}, // parsed contents of document.json
  user: {}, // parsed contents of user.json
  meta: {}, // parsed contents of meta.json
  pages: {
    '0F364A54-A488-4D6F-BAA4-F93FB057C5A3': {}, // parsed contents of pages/0F364A54-A488-4D6F-BAA4-F93FB057C5A3.json, and so on for every page file
    ...
  }
}

In the browser

In the browser, it depends on how you read the file. If you get it from a FileReader you will need to make sure to read it as an ArrayBuffer. The implementation in the demo is a little complex but might be of help.

Get a Folktale Task monad instead of a Promise:

const fs = require('fs')
const sketch2json = require('sketch2json')

fs.readFile(__dirname + '/simple.sketch', (error, data) => {
-  sketch2json(data).then(result => console.log(result))
+  sketch2json(data, {task: true}).map(result => console.log(result)).run()
})

What is the structure of the contents of each file?

As far as I know, there is no official documentation yet.

Meanwhile here you can find Flowtype definitions for Sketch 43+ JSON by @darknoon to use as guide.

Related

  • sketch-loader Webpack loader for Sketch v43+ files, uses this lib underneath the hood

License

Unlicense

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].