JavaScript Object to JSON Converter (JSON5 Validator)
Turn a JavaScript object literal or JSON5 into strict JSON: unquoted keys, single quotes, comments, trailing commas, hex, Infinity. Also checks JSON5.
The declaration around the value (const config =) was ignored.
1 Infinity/NaN value became null, as JSON.stringify does.
undefined values were left out of objects and became null in arrays, as JSON.stringify does.
Not valid JSON5 because of: numeric separator at line 9, column 35; template literal at line 10, column 13; undefined at line 12, column 10. The JSON is still correct.
Keys stay in the order written. (A JavaScript object would list integer-like keys such as "1" first.)
A JavaScript object literal copied from code — unquoted keys, single quotes, comments, trailing commas, hex numbers — is not JSON, and JSON.parse rejects it. This converter reads the literal without running it and writes strict JSON, the same as JSON.stringify would produce. It understands everything in JSON5 plus common JavaScript extras such as template literals, numeric separators, BigInt and undefined, and tells you whether the input is valid JSON5, so it also works as a JSON5 validator.
How to use this tool
- Paste the object, array or JSON5 text — a "const x =" declaration around it is fine.
- Choose the indentation.
- Decide how Infinity and NaN are written (JSON has no such numbers).
- Copy the JSON; the "Input is" line says whether the input was strict JSON, JSON5 or JavaScript only.
Formula
{ key: 'v', } → {"key": "v"} · 0x1F → 31 · .5 → 0.5 · 1_000 → 1000 · undefined → left out · Infinity → null
JSON5 adds to JSON: identifier keys, single-quoted strings, escaped line breaks, \x escapes, comments, trailing commas, hexadecimal numbers, leading or trailing decimal points, a + sign, Infinity and NaN. JavaScript also allows template literals without ${…}, numeric separators, 0o/0b numbers, BigInt (10n), numeric keys and undefined; these convert but are reported as not JSON5. Numbers keep their digits, so long IDs are not rounded. Variables, function calls, shorthand properties and ${…} cannot be evaluated and are reported with their line and column — nothing is executed.
Example
The sample config becomes {"host": "localhost", "port": 8080, "content-type": "application/json", "retries": 3, "timeout": 0.5, …}: 0x3 becomes 3, .5 becomes 0.5, 1_000 becomes 1000, Infinity becomes null, the template literal becomes "Hello\nworld" and debug: undefined is dropped. "Input is" reports JavaScript only — not JSON5 because of the template literal, the numeric separator and undefined.
Frequently asked questions
Is JSON5 the same as a JavaScript object?
Almost: JSON5 is a subset of ES5 object literals. It has unquoted keys, single quotes, comments, trailing commas, hex numbers and Infinity, but not template literals, BigInt, numeric separators or undefined.
Why did my key order stay the same when JSON.stringify changes it?
JavaScript objects list integer-like keys ("1", "2") before other keys. This converter keeps the order you wrote, which describes the same object.
Does it run my code?
No. It only reads literal values. Anything that would need code to run — a variable, a function call, ${…} — is reported as an error.
Is my data uploaded?
No. Conversion happens in your browser.
Sources
Last updated:
Page address with these inputs: https://kakao.mobile/tools/javascript-object-to-json-converter/
Cite or embed this tool
kakaoCalc. (2026, November 8). JavaScript Object to JSON Converter (JSON5 Validator). https://kakao.mobile/tools/javascript-object-to-json-converter/
“JavaScript Object to JSON Converter (JSON5 Validator).” kakaoCalc, 8 Nov. 2026, kakao.mobile/tools/javascript-object-to-json-converter/.
Paste this code into your page. The widget runs in your visitors' browsers, shows no ads and keeps a link back to this page. Embedding terms