Paste JavaScript on the left and click "Convert" — we will turn it into JSONPaste JavaScript

What this tool does

You have copied a JavaScript object literal out of a config file, a seed script, or a debugger, and now you need it as real JSON. The catch: JS lets you use unquoted keys, single quotes, trailing commas, undefined, comments, and new Date(...) — none of which are legal in JSON. Paste the whole thing here, hit Convert, and you get back JSON that would round-trip through JSON.parse without a single red squiggle.

It follows the same rules JSON.stringify applies: keys get double-quoted, single-quoted strings flip to double, trailing commas are dropped, comments are stripped, undefined values disappear (same as native stringify behaviour), NaN and Infinity turn into null, and Date objects become ISO-8601 strings per RFC 8259. The ECMAScript number formatting rules are respected, so 1e3 stays as a number and 0x1F becomes 31.

It also handles things you paste from Nodemodule.exports = {...}, ES export default {...}, or a plain const config = {...} assignment. Computed keys, shorthand properties ({ name }), and spread ({ ...defaults, env: "prod" }) are all expanded to their resolved shape. Nested objects and arrays come through intact.

How to use it

Three steps, regardless of whether you are pasting five lines or a full config module.

1

Paste your JavaScript (or try the sample)

Drop the code into the left editor. An object literal, an array of objects, an export statement, or a const declaration — the parser handles each. Click Load Sample to see a realistic input.

No need to strip const, module.exports, or export default. Leave comments in if you like — they will be removed in the output. See the MDN JSON reference if you want a refresher on the exact JSON type mapping.

2

Hit Convert

Click the green Convert button. The tool parses the JS, evaluates literal values, and serializes them the same way JSON.stringify(obj, null, 2) would.

3

Copy the JSON

The right panel shows pretty-printed JSON that parses cleanly in any language. Copy it into your request body, config file, or Jest snapshot.

When this actually comes in handy

Seeding API requests

You have an object literal from a React or Express file and need a JSON body for Postman or curl. Paste, convert, done.

Porting config to JSON

Migrating from a <code>config.js</code> file to a JSON-based config store? Paste the export, get valid JSON, drop it in.

Test fixtures and mocks

Convert an inline object used in a Jest test into a standalone JSON fixture for MSW, Playwright, or a mock server.

Logs and debugger output

Copy a value printed by the Node REPL or Chrome DevTools (which use JS object syntax, not JSON) and turn it into something downstream tools can actually parse.

Common questions

Do unquoted keys and trailing commas work?

Yes. Unquoted identifier keys are quoted in the output, single quotes flip to double, and trailing commas are dropped — matching what ECMAScript allows but JSON does not.

What happens to undefined, NaN, Infinity, and functions?

Same rules as JSON.stringify: undefined and function values are omitted from objects, NaN and Infinity become null, and Symbol is dropped. See the MDN JSON.stringify docs for the full list.

Are Dates serialized?

Yes. new Date(...) values become ISO-8601 strings ("2026-03-14T10:30:00.000Z"), which is the same format Date.prototype.toJSON() produces.

Can I paste an ES module or CommonJS export?

Yes — export default { ... }, export const x = { ... }, and module.exports = { ... } are all recognized. The tool extracts the exported value and converts that.

What about spread syntax and computed keys?

Both are resolved to the final object shape. { ...defaults, env: "prod" } is merged, and { [name]: value } becomes { "actualName": value } when the key is a literal.

Is my code stored?

Code is sent to the backend to be converted and is not persisted or logged. If you are pasting something sensitive, give it a read-through first.

Other tools you may need

JavaScript to JSON is one piece of the puzzle. Here are the tools that pair well with it: