Paste your JavaScript object literal and instantly get valid, formatted JSON. Automatically handles unquoted keys, trailing commas, and single quotes. Includes key sorting and customizable indentation options.
Paste your JavaScript object literal and instantly get valid, formatted JSON. Automatically handles unquoted keys, trailing commas, and single quotes. Includes key sorting and customizable indentation options.
Common questions and answers about this topic.
JavaScript objects allow unquoted keys, single quotes, trailing commas, and methods. JSON requires double-quoted keys and only supports strings, numbers, booleans, null, arrays, and objects. This tool automatically converts JS syntax to valid JSON.
Yes, the sort keys dropdown enables you to arrange all JSON object keys in alphabetical order (A to Z) or keep the property order from your JavaScript source. Sorting applies recursively across every nested JSON object.
Yes, choose between 2 spaces, 4 spaces, or tabs for the JSON output indentation via the formatting options. For API responses, 2-space indentation is standard; for human-readable config files, 4 spaces may be preferable.
No, the JS object to JSON conversion is performed entirely client-side in your browser. Your JavaScript code is parsed locally and never transmitted to any external server.