The converter parses the input with JSON5 before emitting formatted JSON. That means data-shaped object literals can use unquoted keys, single quotes, comments, and trailing commas, then be printed with preserved or alphabetized key order.
The output is strict JSON, so it only keeps values JSON can represent. Functions, methods, prototypes, computed properties, and undefined are not valid JSON values and should be removed or rewritten before conversion.
Common questions and answers about this topic.
JavaScript object literals can use unquoted keys, single quotes, comments, and trailing commas when written as JSON5-style data. JSON requires double-quoted keys and only supports strings, numbers, booleans, null, arrays, and objects. Functions, methods, undefined, and computed properties must be removed before conversion.
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.