Converts a JSON string into a valid JavaScript object
Select a JSON string in the editor and in press Ctrl+Shift+J
(⌘+⇧+J
on Mac OS) or open the command pallete Ctrl+Shift+P
(⌘+⇧+P
on Mac OS) and type Convert JSON into JS object
.
It is especially useful when you're using a linter with strict rules on code styling. eg.: ESLint + eslint-config-airbnb
You can customize the options in Settings / Extensions / JSON to JS converter. Below are the available options: (requires VSCode restart)
Adds a trailing comma in the end of every object or array keys. Makes the result object source control friendly.
Default: True
Sets the number of spaces used in indentation.
Default: 2
The default keybind to convert JSON strings into JS objects is Ctrl+Shift+J
(⌘+⇧+J
on Mac OS)
-- Option to add trailing commas -- Customizable indentation size -- Default keybing
-- Stability improvements
-- Initial Release