Skip to content
BrowserUtil

JS Object to JSON

Convert JavaScript / TypeScript object literals to clean standard JSON (and back). Supports unquoted keys, single quotes, comments, trailing commas, and formatting options.

Indent:
Undefined:
Functions:

JavaScript Object

Paste or type a JavaScript object or JSON.
0 characters · 0 lines · 0 B

JSON Output

Converted result will appear here.
0 characters · 0 lines · 0 B

How to use

  1. 1 Paste or type your JavaScript object literal, config snippet, or JSON into the left editor.
  2. 2 Select conversion mode: 'JS Object → JSON' or 'JSON → JS Object'.
  3. 3 Adjust formatting options such as indentation (2/4 spaces/tab/minify), sorting keys, or quote preferences.
  4. 4 Copy the result with one click or download it as a .json or .js file.

Features

  • Parses JavaScript object literals, arrays, and variable declarations (const, let, var, export default)
  • Supports unquoted keys, single quotes, template literals, and trailing commas
  • Strips single-line (//) and multi-line (/* */) comments automatically
  • Handles undefined, NaN, Infinity, BigInt, Dates, RegExps, and functions with customizable options
  • Two-way conversion: JS Object to JSON and JSON to JS Object with unquoted keys and quote options
  • 100% client-side execution — fast, secure, and completely private

Frequently asked questions

What is the difference between a JavaScript Object and JSON?

JSON is a strict data interchange format requiring double-quoted property names and forbidding comments, single quotes, trailing commas, and function/undefined values. JavaScript objects are flexible code constructs that support unquoted keys, single quotes, template strings, comments, trailing commas, and complex types.

Can I convert console.log output or variable declarations?

Yes! You can paste objects copied directly from console.log output, code files, or variable declarations like 'const config = { ... };' or 'export default { ... };'. The converter automatically extracts the object payload.

How does it handle functions, undefined, and Dates?

By default, functions and undefined are omitted in JSON mode, conforming to standard JSON.stringify behavior. You can also configure them to convert to null or keep functions as stringified representations. Dates are converted to ISO 8601 strings.

Is my data sent to any server?

No. All conversion is executed entirely in your browser using client-side JavaScript. Your code and data never leave your device.

Related tools