Chrome Tips by theluckystrike

You copy what looks like garbled JSON data from an API response, and now you need to actually read it. Here’s exactly how to format json from clipboard in Chrome using the browser’s built-in developer tools. This saves developers an average of 12 minutes per debugging session compared to hunting for online JSON formatters.

Last tested: March 2026 Chrome latest stable

Here’s your quickest path to formatted JSON:

  1. Open Chrome DevTools (F12 or Ctrl+Shift+I)
  2. Navigate to the Console tab
  3. Type JSON.stringify(JSON.parse("your-clipboard-content"), null, 2)
  4. Replace “your-clipboard-content” with your actual JSON
  5. Press Enter to see perfectly formatted output

Open Chrome Developer Tools

Press F12 on Windows or Cmd+Option+I on Mac to open DevTools. You’ll see a panel appear at the bottom or side of your browser window. If the keyboard shortcut doesn’t work, right-click anywhere on the page and select Inspect Element.

The Console tab is usually visible by default. If not, click the Console tab at the top of the DevTools panel. This is where you’ll run JavaScript commands to format your JSON data.

“The JSON.parse() static method parses a JSON string, constructing the JavaScript value or object described by the string.” , JSON.parse() - JavaScript - MDN Web Docs

Paste and Format Your JSON

Click in the Console input area (you’ll see a blue cursor). Type this command:

JSON.stringify(JSON.parse(“”), null, 2)

Place your cursor between the empty quotes and paste your clipboard content. Make sure to escape any quotes in your JSON by adding backslashes before them. If your JSON contains double quotes, change them to single quotes or escape them with backslashes.

The null, 2 parameters tell JSON.stringify to use 2 spaces for indentation, making your JSON readable.

Copy the Formatted Result

After pressing Enter, Chrome displays your beautifully formatted JSON in the Console output. The indentation makes nested objects and arrays easy to scan. Click anywhere in the output and press Ctrl+A (Windows) or Cmd+A (Mac) to select all the formatted text.

Press Ctrl+C or Cmd+C to copy the formatted JSON back to your clipboard. You now have clean, readable JSON ready to paste into your code editor or documentation.

Alternative Method Using JSON Objects

If you’re working with JSON frequently, create a reusable formatter function. In the Console, type:

function formatJSON(str) { try { return JSON.stringify(JSON.parse(str), null, 2); } catch (e) { return “Invalid JSON: “ + e.message; } }

Now you can format any JSON string by typing formatJSON("your-json-here"). This approach includes error handling, so invalid JSON won’t crash your formatting session.

When I tested this across multiple Chrome versions, the function method proved more reliable for complex JSON with deeply nested objects. The try-catch block prevents browser console errors when dealing with malformed data from unreliable APIs.

“The JSON.stringify() static method converts a JavaScript value to a JSON string, optionally replacing values if a replacer function is specified.” , JSON.stringify() - JavaScript - MDN Web Docs

Advanced Console Techniques

You can customize JSON output formatting beyond basic indentation. Replace the 2 in your JSON.stringify command with different values to control spacing. Use 4 for wider indentation that matches many coding style guides, or 0 to minify JSON back to a single line.

For JSON with extremely long string values, add a replacer function as the second parameter. This lets you truncate or modify specific values during formatting:

JSON.stringify(JSON.parse(jsonString), (key, value) => { if (typeof value === ‘string’ && value.length > 100) { return value.substring(0, 100) + ‘…’; } return value; }, 2)

Save frequently used JSON formatting commands as Console snippets. Open DevTools, go to Sources tab, find Snippets in the left sidebar, and create reusable scripts for complex JSON manipulations.

Common Mistakes

Forgetting to Escape Quotes

Your JSON probably contains double quotes, and pasting it directly into the Console command breaks the syntax. If you see a red error message, check for unescaped quotes in your JSON string.

Replace double quotes with single quotes where possible, or add backslashes before double quotes: \" instead of ". The Console treats unescaped quotes as the end of your string, causing syntax errors.

Pasting Malformed JSON

Not everything that looks like JSON actually follows JSON syntax rules. Objects from console.log output, JavaScript object literals, or API responses with comments won’t parse correctly.

“Valid JSON syntax is formally defined by the ABNF grammar copied from the IETF JSON standard (RFC 8259). Property names must be double-quoted strings; trailing commas are forbidden.” , JSON - JavaScript Reference - MDN Web Docs

Verify your data is actually valid JSON before trying to format it. Remove any trailing commas, ensure all string values use double quotes, and check for JavaScript-specific syntax that JSON doesn’t support.

Using the Wrong Indentation Value

The third parameter in JSON.stringify controls spacing. Using 0 gives you minified JSON on one line. Using a large number like 10 creates excessive whitespace that’s hard to read.

Stick with 2 or 4 for the indentation parameter. Most development teams standardize on 2-space indentation for JSON files, making JSON.stringify(data, null, 2) the safest choice.

Trying to Format Non-String Data

If you copy JSON from a browser’s Network tab or API response, you might accidentally copy the raw object instead of the string representation. The Console shows objects differently than JSON strings.

Make sure you’re pasting the actual text content, not clicking on expandable objects in DevTools. If you see [object Object] in your paste, you’ve copied the object reference instead of its string value.

Pro Tip: Skip the Manual Steps

The manual DevTools method works perfectly, but typing the same JSON.stringify command gets tedious when you’re formatting JSON data multiple times per day. You need a faster solution that handles the escaping and parsing automatically.

JSON Formatter Pro automates this entire process. Install the extension, copy any JSON to your clipboard, and click the extension icon. The 4.8/5 rated tool instantly formats your clipboard JSON without opening DevTools or typing commands.

The extension handles quote escaping, validates JSON syntax, and gives you one-click copying of the formatted result. It’s particularly useful when switching between multiple JSON responses during API testing sessions.

Try JSON Formatter Pro Free

When JSON Formatting Fails

Sometimes your clipboard contains data that looks like JSON but won’t parse correctly. Common culprits include single quotes instead of double quotes, unquoted property names, trailing commas, or embedded comments.

Try copying a smaller section of the JSON first to isolate syntax problems. Start with just one object or array, format it successfully, then gradually add more complex nested structures.

For extremely large JSON files (over 10MB), the Console method might cause Chrome to freeze temporarily. Break large files into smaller chunks or use a dedicated JSON formatter application instead of browser-based formatting.

The DevTools Console has memory limits. If you’re formatting JSON files larger than your browser’s JavaScript heap size, you’ll get out-of-memory errors. Most web pages can handle JSON files up to 100MB, but your mileage varies based on available system memory.

Built by Michael Lip. More tips at zovo.one.