0
Input Characters
Convert JavaScript object and configuration-style data into valid JSON directly in your browser.
Input Characters
Output Characters
Size Change
JSON Lines
JavaScript to JSON Converter is a browser-based developer tool for converting JavaScript object-style and configuration-style data into standard JSON. It is designed for situations where data has been written using JavaScript syntax but needs to be stored, exchanged, or consumed as JSON.
The converter works with data-like JavaScript structures rather than arbitrary executable JavaScript programs. Your input is processed locally in the browser, and the converter does not need to execute the supplied code.
JSON, or JavaScript Object Notation, is a text-based data format commonly used for APIs, configuration files, application data, and communication between software systems. JSON uses a strict syntax for objects, arrays, strings, numbers, booleans, and null values.
Although JSON syntax is closely related to JavaScript object syntax, the two formats are not identical. For example, JSON requires object property names to use double quotes, while JavaScript object literals can use unquoted identifier-style property names.
A JavaScript object can contain syntax that is not permitted by the JSON specification. For example, comments, trailing commas, single-quoted strings, and unquoted identifier-style keys can appear in JavaScript-style data.
JSON is intentionally more restrictive because it is designed as a predictable data interchange format. The converter normalizes supported JavaScript-style syntax before generating the final JSON.
A JavaScript-style object may look like this:
{
name: 'John',
age: 30,
active: true,
address: {
city: 'Dhaka'
},
}
The converter can transform the supported syntax into standard JSON such as:
{
"name": "John",
"age": 30,
"active": true,
"address": {
"city": "Dhaka"
}
}
name or price without
quotes.
The converter is intended for plain data structures that can be represented by JSON. Supported input can include:
true and false.
null value.
const data = {...}.
Not every JavaScript program can be converted into JSON. JSON describes data; it does not describe executable program logic.
The following JavaScript features are not valid JSON data and are not executed by this converter:
undefined.
NaN.
Infinity.
Conversion is performed in your web browser. The
converter does not use eval() or
Function() to execute the supplied
JavaScript. This is important because arbitrary
JavaScript execution could create unnecessary
security risks.
Even though processing happens locally, you should still avoid pasting passwords, private keys, authentication tokens, API secrets, or other highly sensitive information into any online tool.
| Pros | Cons |
|---|---|
| Runs directly in the browser | Does not convert arbitrary executable JavaScript |
| No JavaScript execution required | JavaScript-specific values such as undefined are not valid JSON |
| Supports common object-style syntax | Dynamic expressions require manual conversion |
| Formatting, sorting, copying and downloading included | Intended for data-like structures rather than complete JavaScript applications |
It converts JavaScript object and configuration-style data into valid JSON without executing the supplied JavaScript.
No. JSON is a data format and cannot represent executable JavaScript. Functions, statements, variables, undefined, NaN, Infinity and many other JavaScript-specific constructs cannot be represented as standard JSON.
No. The converter parses supported data-style syntax and does not execute the supplied JavaScript.
The conversion is performed directly in your browser. The converter does not require a conversion server.
Yes. Enable
Convert unquoted object keys
to convert identifier-style keys such as
name, price, and
active into valid JSON property names.
Yes. The Format JSON option generates readable JSON with indentation. Disable it when you want compact JSON.
Yes. Enable Sort object keys to recursively sort object properties in the generated JSON.
Yes. After a successful conversion, use the
Download button to save the result as
converted.json.