Data Format Conversions
JavaScript Object to JSON Converter
Workspace
Options
[1, 2, 3] instead of one item per line.
How to use this tool
- 1Paste a JavaScript object, array or a const/export of one, or open a .js file.
- 2Read any notes about values JSON cannot hold (undefined, NaN, tuples…).
- 3Choose indentation and key sorting.
- 4Copy or download the .json file.
Frequently asked questions
No. A dedicated parser reads the literal; nothing is run with eval or new Function. Variables, function calls and spread (...) are reported as errors with their line and column instead.
They have no JSON form. Properties set to undefined are left out and NaN/Infinity become null, exactly as JSON.stringify does, and a note tells you this happened.
Yes. export default { … }, module.exports = { … } and const name = { … } wrappers are understood. Several exported constants become one JSON object keyed by name.
No. Numbers keep their original digits, so IDs like 12345678901234567890 are not rounded as they would be by JSON.parse and JSON.stringify.
Related tools
JSON to JavaScript Object Converter
Turn JSON into a JavaScript object literal with unquoted keys, your quote style and an export wrapper.
JSON Formatter
Beautify JSON with stable indentation and optional key sorting.
JSON to TypeScript Interface Generator
Generate TypeScript interfaces or type aliases from sample JSON, with nested types and optional fields.
Python Dict to JSON Converter
Convert Python dict, list, tuple and set literals to valid JSON with a safe parser.