Git Product home page Git Product logo

json-to-figma's Introduction

JSON to Figma (Not Maintained)

Notice: This plugin is no longer maintained

Thank you for your interest in the JSON to Figma plugin. As of now, this plugin has become a paid plugin available on the Figma Community. Due to this change, this repository will no longer be updated.


An easy way to use real data in Figma.

The plugin can parse local or JSON files from a URL link. You can populate any layers with text or images.


Get the plugin


πŸ’‘ Features:

  • Load local files and fetch from URL
  • Fetch images
  • Supported image formats: JPG, PNG, GIF, WEBP, SVG
  • Parsing JSON files with any amount of nested levels
  • Flexible keys selection
  • Invert selected keys
  • Populate in random order
  • Select any ranges from JSON file
  • the "skip" rule for layers you won't populate
  • Handle null values

Youtube demo


πŸš€ How to Use

All you need is a proper JSON. The plugin will parse show all available keys from the JSON including nested layers.

  1. Load a JSON file localy or copy a link and the click on the "From Cipboard link" button.
  2. Make sure layers you want to populate have the same names as in the JSON file. For example β€” if you see a key "user.name" key in the plugin the layer name also should be "user.name".
  3. Select layers with items you want to populate. You can select group or frames with these layers, no need to select layers dirictly or manualy, the plugin will find them by their names.
  4. Select keys you want to use for population.
  5. Press "Populate selected" button

🀘 Features

Range seection β€” If you want to select a certain range from a JSON, you can do it like this β€œ1-10”, β€œ1, 5, 20”, or combine them β€œ1-10, 21, 50-340” β€” it means that the plugin will take JSON objects from 1 to 10, 21 and from 50 to 340 and combine them into one new array. Then you can also save filtered array.

Skip marked layers β€” if you want to skip layers, groups or frames β€” exclude them from the list, then you can use the β€œSkip marked layers” option. Just select layers and press β€œSkip selected”. You can also clean marked layers or add the marker manually.

Random order β€” If you switch it on all items will be filled in a random order. By default, all your layers will be filled in order.

Image URLs recognition β€” The plugin will automaticly recognise values from a JSON that end with .JPG, .PNG, .GIF or .WEBP as images. if you name a shape or a frame with the name of the key β€” the pllugin wil fetch the image by URL and add it as a fill.


βœ… Valid JSON structure

The JSON structure for the file should look like an array of objects.

[
    {
        "id": 1,
        "name": "Shannah Judgkins",
        "job": "Database Administrator II",
        "image": "https://robohash.org/suntautvoluptatem.jpg?size=500x500&set=set1"
    },
    {
        "id": 2,
        "name": "Silvester Hallwell",
        "job": "Data Coordiator",
        "image": "https://robohash.org/rerumautemenim.jpg?size=500x500&set=set1"
    }
]

πŸ““ Services to generate JSON data

You can download try different JSON samples from this repo.

Or you can use on of these services:

json-to-figma's People

Contributors

4aficiona2 avatar dependabot[bot] avatar lukaharambasic avatar pavellaptev avatar tomresing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

json-to-figma's Issues

Save selected JSON keys when reuploading

Thanks for your great work!

Every time after reuploading my json file, the selected keys lost. And I need mannually choose them again...
I'd like if there's a way to hot update json or keep selected keys?

"From Clipboard link" doesn't work on web browser version of Figma

On the web browser version of Figma (Chrome/Mac) with the JSON-to-Figma plugin, the "From Clipboard link" doesn't give an user friendly response for an error message that it doesn't work. The user clicks on the button but doesn't give any response if you have a URL with a valid JSON file e.g., https://raw.githubusercontent.com/PavelLaptev/JSON-to-Figma/master/json-test-files/workers-json%2Bimage.json If you open the web browser's console, you can see the error message: SyntaxError: Unexpected toke '<', ">!DOCTYPE "... is not valid JSON The plugin doesn't parse the JSON and stays on the same default plugin dashboard screen without any message.

However, the button works on the desktop version of Figma when clicking on the button with the valid JSON URL on your clipboard. I'm assuming the web browser's not getting the contents of the clipboard? Also, shouldn't there be an user-friendly error message on the plug in to say it is not a valid URL with JSON?

Collapse text layers with no JSON value

Great plugin, thank you! In my component that has an auto layout, I have name, title, and number. In the JSON file if record 2 does not have a title, how can I get the number text layer to be right under the title?

Link local images

Hi,

is it possible to also link to local images… or does the plugin not have access to the local file system?

Thanks :)
Wolfgang

Detail of Error Message

It's difficult to find out the reason of errors, because the message is ambiguous.
If there were detail of error message, I could find the reason of error easly.

Import hexcode to fill

Hi,

Is it possible to have the plugin detect hexcode, and add this as fill for object?

I.e. Masking a colored rectangle on text to change the text color depending on hex value applied to the rectangle

Pulling JSON data on localhost source

Hi Pavel

I’ve been using your plugin for Figma on a project I’m working on (loving the new image replace function, by the way) but I’m running into a problem when trying to import the JSON via a URL.

It seems that I can’t import JSON from a localhost URL or local/protected range IP address because your plugin uses a Heroku proxy server to grab the JSON content, which obviously won’t tunnel in to a URL beginning with http://localhost, http://127.0.0.1 or http://192.168.x.x, etc.

Have I understood that correctly? Does the plugin require the JSON to be on a publicly accessible web server in order to be able to work? If not how do I get a local URL to deliver data to the plugin?

Thanks
Mark G

Support for object and not only array of objects

Hey, would it be possible to also support this kind of json?

{
  "name": "John Doe",
  "age": 32,
  "is_admin": true,
  "skills": ["JavaScript", "HTML", "CSS"]
}

My workaround right now is to put the object into an array. Some APIs simply don't return an array of objects and this change would be really helpful.

downloading images reduces quality

When I download an .svg file, it reduces the quality and does not keep it "vectorized".
Any way to keep the file in the svg format?

On the left of the image you can see a vectorized part while the right part of the image is the result of using your plugin:
image

Fetch json from Clipboard link doesn't work

Trying with https://jsonplaceholder.typicode.com/todos/1 returns "It is not a link"

isLocalhost.tsx:13 It is not a link App.tsx:30 SyntaxError: Unexpected token T in JSON at position 0 showErrorMsg @ App.tsx:30 (anonymous) @ App.tsx:59 (anonymous) @ fetchJSONfromURL.tsx:23 Promise.catch (async) (anonymous) @ fetchJSONfromURL.tsx:22 (anonymous) @ fetchJSONfromURL.tsx:7 ./src/app/utils/fetchJSONfromURL.tsx.__awaiter @ fetchJSONfromURL.tsx:3 fetchJSONfromURL @ fetchJSONfromURL.tsx:15 fetchUrlLink @ App.tsx:54 callCallback @ react-dom.development.js:188 invokeGuardedCallbackDev @ react-dom.development.js:237 invokeGuardedCallback @ react-dom.development.js:292 invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:306 executeDispatch @ react-dom.development.js:389 executeDispatchesInOrder @ react-dom.development.js:414 executeDispatchesAndRelease @ react-dom.development.js:3278 executeDispatchesAndReleaseTopLevel @ react-dom.development.js:3287 forEachAccumulated @ react-dom.development.js:3259 runEventsInBatch @ react-dom.development.js:3304 runExtractedPluginEventsInBatch @ react-dom.development.js:3514 handleTopLevel @ react-dom.development.js:3558 batchedEventUpdates$1 @ react-dom.development.js:21871 batchedEventUpdates @ react-dom.development.js:795 dispatchEventForLegacyPluginEventSystem @ react-dom.development.js:3568 attemptToDispatchEvent @ react-dom.development.js:4267 dispatchEvent @ react-dom.development.js:4189 unstable_runWithPriority @ scheduler.development.js:653 runWithPriority$1 @ react-dom.development.js:11039 discreteUpdates$1 @ react-dom.development.js:21887 discreteUpdates @ react-dom.development.js:806 dispatchDiscreteEvent @ react-dom.development.js:4168

Reduce size of view

the view becomes really long and takes up the entire height. is there a way to have it fixed and scroll within that viewport?

that would allow to see all the settings for the actual plugin

thx for making such a simple plugin!

image

Lists support

We have a list of food ingredients that need to be imported into separate fields.

ie.

...
"ingredientsList": [
  [
    "1 x 20cm pizza base",
    "2 large garlic cloves (or three small), peeled",
    "Flaky sea salt",
    "2 tablespoons extra virgin olive oil",
    "Mozzarella",
    "Parmesan",
    "1 large courgette",
    "Havarti",
    "Gruyere",
    "2 tablespoons pine nuts",
    "1 lemon",
    "Extra virgin olive oil"
  ]
...

Need to be able to reference each ingredient separately, but when we import its showing us the following (for example):

Image Pasted at 2021-6-30 15-39

The data doesnt get pulled in when choosing one of those fields. Any ideas?

Fill in random order: do not fill recurring keys randomly

Scenario

I create the design for an item detail page of an e-commerce shop in Figma. Some information, such as the brand name of a product, is used in several places on the page. I have a JSON file with different products. I now want to fill the page with a random article from the JSON file. Suppose there is a key brandName in the JSON and all the layers in Figma that should display the brand name are named after this key.

Problem

When I select the option Populate in random order to populate the page with a random item, I have a different brand name for each layer named brandName. However, all occurrences of brandName should be given the same brand name, chosen at random. The problem then also occurs for all other keys. As a result, the information no longer fits together.

Possible solution

If the keys are selected randomly (Populate in random order), I can decide whether the randomly selected key from the JSON should apply to all matching layers in Figma. Maybe this is helpful for others as well? I'm not sure if the wording in the UI is appropriate.

πŸ‘‰ Please see my (forked) feature branch.

πŸ‘‡ An example where the key "name" is used twice. Using this json-test-file.

jsontofigma-merge.mov

Thank you for developing this plugin πŸ™

images failing to load

I'm seeing the following error in the Figma console when trying to load an image with the plugin. This feature worked a few days ago.

FYI I changed my image URL to image-url

fetchImagefromURL.tsx:3 GET https://cors-anywhere.herokuapp.com/image-url 403 (Forbidden)
fetchImagefromURL @ fetchImagefromURL.tsx:3
MsgListener @ App.tsx:14
postMessage (async)
postMessageToIframe @ figma_app.d568e097c290c2c6b1a02f4393192d0c.min.js.br:1251
(anonymous) @ figma_app.d568e097c290c2c6b1a02f4393192d0c.min.js.br:1258
e.invokeCallback @ figma_app.d568e097c290c2c6b1a02f4393192d0c.min.js.br:776
ASM_CONSTS @ jsvm-cpp.js.br:8
_emscripten_asm_const_iii @ jsvm-cpp.js.br:8
(anonymous) @ jsvm-cpp.wasm:0x7035
(anonymous) @ jsvm-cpp.wasm:0x4fbb
(anonymous) @ jsvm-cpp.wasm:0x10fdf
(anonymous) @ jsvm-cpp.wasm:0x12c71
(anonymous) @ jsvm-cpp.wasm:0x1422a
(anonymous) @ jsvm-cpp.wasm:0x83894
(anonymous) @ jsvm-cpp.wasm:0x10fdf
(anonymous) @ jsvm-cpp.wasm:0x12c71
(anonymous) @ jsvm-cpp.wasm:0x1422a
(anonymous) @ jsvm-cpp.wasm:0x140b0
(anonymous) @ jsvm-cpp.wasm:0x140b0
(anonymous) @ jsvm-cpp.wasm:0x33702
(anonymous) @ jsvm-cpp.wasm:0x69d7
jsvm_callFunction @ jsvm-cpp.wasm:0x81cf
Module._jsvm_callFunction @ jsvm-cpp.js.br:8
callFunction @ figma_app.d568e097c290c2c6b1a02f4393192d0c.min.js.br:776
callFunction @ figma_app.d568e097c290c2c6b1a02f4393192d0c.min.js.br:779
iframeMessageHandler @ figma_app.d568e097c290c2c6b1a02f4393192d0c.min.js.br:1258
windowMessageEventListener @ figma_app.d568e097c290c2c6b1a02f4393192d0c.min.js.br:1251
p @ vendor.1238b887754a64878f02249c8334814f.min.js.br:183
postMessage (async)
messageHandler @ plugin-sandbox:16
postMessage (async)
handleClick @ index.tsx:11
callCallback @ react-dom.development.js:188
invokeGuardedCallbackDev @ react-dom.development.js:237
invokeGuardedCallback @ react-dom.development.js:292
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:306
executeDispatch @ react-dom.development.js:389
executeDispatchesInOrder @ react-dom.development.js:414
executeDispatchesAndRelease @ react-dom.development.js:3278
executeDispatchesAndReleaseTopLevel @ react-dom.development.js:3287
forEachAccumulated @ react-dom.development.js:3259
runEventsInBatch @ react-dom.development.js:3304
runExtractedPluginEventsInBatch @ react-dom.development.js:3514
handleTopLevel @ react-dom.development.js:3558
batchedEventUpdates$1 @ react-dom.development.js:21871
batchedEventUpdates @ react-dom.development.js:795
dispatchEventForLegacyPluginEventSystem @ react-dom.development.js:3568
attemptToDispatchEvent @ react-dom.development.js:4267
dispatchEvent @ react-dom.development.js:4189
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
discreteUpdates$1 @ react-dom.development.js:21887
discreteUpdates @ react-dom.development.js:806
dispatchDiscreteEvent @ react-dom.development.js:4168
vendor.1238b887754a64878f02249c8334814f.min.js.br:152 Error: in createImage: Image type is unsupported
    at <anonymous> (PLUGIN_3_SOURCE:594)

Cannot communicate to server. Images, and "copy from clipboard link" are erroring.

The following console error happens when I try to populate an image:

CleanShot 2022-12-13 at 19 12 50@2x

Here's my JSON file:
CleanShot 2022-12-13 at 19 15 51@2x

Both the layer name and JSON key are identical. (I've tried changing both to a different label, and the same problem persists).
The image downloads if I paste the image URL in the browser.
I tried closing and opening Figma again. I'm using Figma Desktop App version 116.5.18 on Mac.

Am I the only one experiencing this problem?

Idea: Handling `null` types

Thank you so much for the plugin, it has radically increased my productivity.

I did think of a small improvement. When items are currently null, the plugin throws an error. Instead, is there a way to hide the layer for the null values?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.