User Agents

Web browsers and everyday web tech, explained

How to View JSON Files in Chrome

· 6 min read · Browsers

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Viewing JSON files in Chrome is straightforward: you can open a local JSON file by dragging it into a Chrome tab, or you can view JSON from a URL by pasting the link into the address bar. By default, Chrome displays raw JSON as plain text, which can be hard to read. To make it more readable, you can use a browser extension or a built-in developer tool. This guide covers both methods, plus tips for formatting and troubleshooting.

What You'll Need

  • Google Chrome installed on your computer (any recent version).
  • A JSON file saved on your computer, or a URL that returns JSON data.
  • Optional: A Chrome extension like "JSON Viewer" or "JSON Formatter" for pretty-printing.

Step-by-Step

  1. Open Chrome. Launch Chrome from your desktop, taskbar, or Start menu.
  2. View a local JSON file: Drag the .json file from your file explorer (Windows) or Finder (Mac) directly into a Chrome tab. The file will open in the browser, showing the raw JSON text.
  3. View JSON from a URL: If you have a web address that returns JSON (for example, an API endpoint), type or paste the URL into Chrome's address bar and press Enter. The JSON will appear as plain text.
  4. Use Chrome's built-in viewer (optional): If the JSON is not too large, Chrome may automatically render it in a tree view. This happens when the server sends the correct Content-Type: application/json header. If you see plain text, proceed to the next step.
  5. Install a JSON viewer extension: Go to the Chrome Web Store and search for "JSON Viewer" or "JSON Formatter". Choose a well-reviewed extension (e.g., "JSON Viewer" by gildas-lormeau). Click "Add to Chrome" and confirm the installation.
  6. Use the extension: Once installed, the extension will automatically format any JSON you open in Chrome. Refresh the tab if you already had a JSON file open. You'll see collapsible trees, color-coded syntax, and line numbers.
  7. View JSON in Developer Tools (alternative): If you prefer no extensions, open Chrome's DevTools by pressing F12 or Ctrl+Shift+I (Windows/Linux) or Cmd+Option+I (Mac). Go to the "Network" tab, reload the page, and click on the request that returns JSON. In the "Preview" or "Response" tab, you can see the JSON in a structured format.
  8. Copy or save formatted JSON: With an extension, you can often copy the formatted JSON to your clipboard or download it as a .json file using the extension's toolbar buttons.

Common Mistakes

  • Dragging a JSON file into a Chrome window with multiple tabs: This may open the file in a new tab, but if you drop it on the wrong area, it might not open at all. Ensure you drop it onto the tab strip or the address bar.
  • Expecting Chrome to format JSON by default: Chrome does not pretty-print JSON by default for local files or most URLs. It just shows raw text unless the server sends the correct header and the file is small enough.
  • Using a JSON viewer extension but not refreshing: After installing an extension, you must refresh the JSON tab for it to take effect.
  • Opening JSON from a URL that requires authentication: If the API requires a login or API key, Chrome will not automatically include those credentials. You'll need to handle authentication separately.

Tips

  • Use the "JSON Viewer" extension for large files: It can handle files that are several megabytes without crashing, whereas Chrome's built-in viewer might struggle.
  • Check the Content-Type header: If you're a developer, ensure your server sends Content-Type: application/json. This helps Chrome and extensions recognize the file as JSON.
  • Use the "Search" feature: In the DevTools Network tab, you can search within the JSON response using Ctrl+F (or Cmd+F). This is handy for finding specific keys or values.
  • Copy as cURL: In DevTools, right-click a network request and select "Copy as cURL" to reproduce the request in the command line, which can be useful for testing APIs.
  • Validate JSON: If you're unsure whether your file is valid JSON, use an online validator or a text editor with JSON support. Chrome will show a syntax error if the file is malformed, but it may not be descriptive.

Troubleshooting

  • The JSON file opens as a download instead of displaying in the browser: This happens when the server sends a Content-Disposition: attachment header. To view it in Chrome, you can try dragging the downloaded file into a new tab, or use a local file viewer. For URLs, you may need to use a tool like Postman or a browser extension that forces inline display.
  • The extension isn't working: Make sure the extension is enabled (check chrome://extensions). Try disabling and re-enabling it, or restart Chrome. Also, ensure you're not in Incognito mode unless the extension is allowed there.
  • JSON appears as a blank page: This can happen if the file is empty or the server returns an error. Check the Network tab in DevTools for the HTTP status code. If it's 404 or 500, the URL is wrong or the server has an issue.
  • JSON is too large and Chrome freezes: For very large files (hundreds of MB), Chrome may become unresponsive. Use a text editor like VS Code or Notepad++ to open the file instead, or split the file into smaller parts.
  • JSON is not formatted even with an extension: Some extensions only work on URLs that start with http or https. For local files, you may need to use the extension's "Open local file" option or drag the file into the extension's popup.

Frequently Asked Questions

Can I view JSON files in Chrome without an extension?

Yes, you can open the file and see raw text, but it won't be pretty-printed. For a tree view, you can use DevTools' Network tab when the JSON comes from a web request.

Why does my JSON show as plain text?

Chrome does not automatically format JSON. It displays it as plain text unless a JSON viewer extension is installed, or the server sends the correct Content-Type header and the file is small enough for Chrome's built-in viewer.

How do I open a JSON file from the command line in Chrome?

You can use the command chrome on Windows, or open -a "Google Chrome" file.json on Mac. This will open the file in a new tab.

Is there a way to edit JSON in Chrome?

Chrome itself is not an editor. You can use DevTools' Sources panel to edit a JSON file if it's part of a web page, but for local files, you'll need a text editor or a dedicated JSON editor.

Can I view JSON from an API that requires a login?

You can use Chrome's DevTools to inspect the network traffic after logging in through the website. For direct API calls, you may need to use a tool like Postman or a browser extension that supports custom headers.

What is the best JSON viewer extension for Chrome?

Popular options include "JSON Viewer" by gildas-lormeau and "JSON Formatter" by callumlocke. Both are free and well-reviewed. Choose one that suits your needs, as they have slightly different features.