JavaScript / JSON Converter is a free online developer tool to convert between JavaScript objects and JSON data with your preferred indentation level.
This tool is split into two modes: JavaScript to JSON
and JSON to JavaScript
.
JavaScript to JSON - Converts a JavaScript object to JSON data. Enter a valid JavaScript object, select your preferred indentation level, and then click the convert button. An example can be found below.
Input JavaScript object:
{ a: 1, b: 2 }
Output JSON:
{ "a": 1, "b": 2 }
JSON to JavaScript - Converts JSON data to a JavaScript object. Opposite to the example above.
You can either browse a JSON file locally from your device, fetch JSON data from a URL/API, or enter it manually.
Select your preferred indentation level, and then click the convert button. The result will be displayed accordingly. Here is an example.
Input JSON:
{ "a": 1, "b": 2 }
Output JavaScript object:
{ a: 1, b: 2 }
Once done converting, you can either copy the output string to your clipboard or download it as a file to your device using the download button.