↔ JAVASCRIPT · CONVERTER

JSON ↔ JavaScript Object Converter

Convert strict JSON to a JavaScript data literal—or convert a plain JavaScript object or array literal back to JSON. The source is parsed locally and never executed.

Safe AST parsing · No eval · Local worker · 1 MiB input limit
Only JSON-compatible data is accepted; functions, getters and expressions are rejected.Need JSON formatting? JSON Formatter →
JavaScript data literalPaste or open local file
Strict JSON
Input: 0 B
Output: 0 B
Warnings: 0
No execution · No upload · Browser worker
◆ ABOUT THIS TOOL

Convert data, not executable code

A safe bridge between strict JSON and simple JavaScript data literals.

JavaScript → JSON

Accepts a single object, array, or scalar literal: strings, finite numbers, booleans, null, nested objects and arrays. Comments and a trailing semicolon are okay.

JSON → JavaScript

Converts strict JSON, preserves the original digits of numeric tokens, and can quote all keys. The special __proto__ key is emitted as a computed own property.

Unsafe expressions rejected

No eval, function calls, variables, getters, methods, spreads, sparse arrays, BigInt, non-finite numbers or computed expressions are executed or converted.

HOW IT WORKS

Local parsing with explicit limits

JavaScript input is parsed by the self-hosted Acorn parser in a web worker. The tool inspects the resulting syntax tree and rebuilds JSON data; it never runs your source. Duplicate keys and values that cannot be represented in JSON are rejected rather than silently changed.

When converting JSON to JavaScript, numeric text is retained. A warning appears for integers outside JavaScript’s safe integer range because those may be rounded when the resulting literal is evaluated by a JavaScript runtime.

Input and formatted output are limited to 1 MiB and 8 MiB respectively, with nesting and value-count guards. Large outputs are previewed in the editor; Copy and Download include the full result.

Use quoted strings for large identifiers, timestamps and account numbers. A number can be syntactically valid JSON yet still lose precision when used as a JavaScript Number.

FAQ

Frequently Asked Questions

No. It parses source into a syntax tree and accepts only plain data values. It never calls eval or executes the input.

They are executable behavior, not JSON data. The converter accepts simple key:value entries and JSON-compatible values only, so it can convert without invoking code.

No. Those values do not have direct JSON equivalents. Convert them intentionally—for example, use a quoted string for an identifier—before converting.

No. The parser and converter run locally in a browser worker. The tool does not upload or save the source.