• Stars
    star
    3,473
  • Rank 12,826 (Top 0.3 %)
  • Language
    TypeScript
  • License
    BSD 3-Clause "New...
  • Created over 12 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Makes JSON easy to read.

JSON Formatter - the original

Chrome extension that auto-formats JSON when you view it in a browser tab.

Features

  • Fast, even on very long JSON pages
  • Dark mode
  • Syntax highlighting
  • Collapsible trees, with indent guides
  • Clickable URLs
  • Negligible performance impact on non-JSON pages (less than 1 millisecond)
  • Works on any valid JSON page – URL doesn't matter
  • Buttons for toggling between raw and parsed JSON
  • Parsed JSON is exported as a global variable, json, so you can inspect it in the console*

*Typing json the in console is not working since Manifest v3. If you need a workaround, paste this snippet into the console:

json = JSON.parse(document.getElementById("jsonFormatterRaw").querySelector("pre").innerText)

Some JSON documents for testing it on: https://callumlocke.github.io/json-formatter/

Installation

Option 1 (recommended) – Install it from the Chrome Web Store.

Option 2 – Install it from source (see below).

Development

Requirements: Deno (and Node for now).

Initial setup:

  • Clone repo
  • Run pnpm i to get TypeScript typings for chrome (or use npm i if you prefer)
  • Optional: if using VSCode and you need to mess with the Deno build scripts, install the official Deno plugin and set "deno.enablePaths": ["tasks"].

To build it:

  • Run deno task build

To build and rebuild whenever files change:

  • Run deno task dev

To install your local build to Chrome

  • Open Chrome and go to chrome://extensions
  • Enable "Developer mode",
  • Click "Load unpacked",
  • Select the dist folder you built above.

FAQ

Why are large numbers not displayed accurately?

This is a limitation of JavaScript and therefore a limitation of JSON as interpreted by your web browser.

  • Anything above Number.MAX_SAFE_INTEGER (2^53 - 1 or 9007199254740991) is adjusted down to that number.
  • Anything below Number.MIN_SAFE_INTEGER (-2^53 + 1 or -9007199254740991) is adjusted up to that number.
  • Extremely precise floating point numbers are rounded to 16 digits.

It's not JSON Formatter doing this, it's the native JSON.parse in V8. JSON Formatter shows you the parsed values, exactly the same as what you'll see after loading the JSON in JavaScript.

If your API endpoint really needs to represent numbers outside JavaScript's safe range, it should quote them as strings.

Why are object keys sometimes in the wrong order?

What you see in JSON Formatter is a representation of the parsed object/array. It's the same order you'll get with Object.keys( JSON.parse(json) ) in JavaScript.

Historically, the JavaScript standard explicitly stated that object keys can be iterated in any order, and V8 took advantage of this by moving numeric string keys (like "1" or "99999") to the top to facilitate a small performance optimisation. This V8 implementation detail has since become standardised.

But I just want to see exactly what the server spits out

For now, your best option is to just use the "Raw" button to see the raw JSON. This is what the server sent. The "Parsed" buttons represents what you'll get from JSON.parse.

In future JSON Formatter might switch from using JSON.parse to a custom parser (if performance allows) in order to detect when a value has been 'changed' by parsing and show an appropriate warning.

More Repositories

1

esbox

πŸ“¦ ES.next in a box
JavaScript
112
star
2

grunt-cdnify

Grunt plugin for finding and modifying static resource URLs
JavaScript
60
star
3

startfrom

🎬 Use any Github repo as a template for a new project
JavaScript
27
star
4

plain-jsx

Alternative JSX renderer. Creates plain DOM nodes instead of React objects.
JavaScript
20
star
5

input

Prompt for user input through the terminal
JavaScript
10
star
6

multiform

Write NPM modules in ES6/7 with multiple builds optimised for different V8 versions
JavaScript
6
star
7

grunt-embed

Inlines external small scripts and stylesheets
CoffeeScript
5
star
8

css-url-rewriter

Runs your callback for every URL found in a string of CSS
JavaScript
5
star
9

in-place

Fast, low-garbage, mutative functions for manipulating arrays.
JavaScript
4
star
10

soup

Query and manipulate raw markup via CSS selectors, without losing original formatting
CoffeeScript
3
star
11

resource-embedder

Embeds the contents of external scripts and stylesheets into HTML.
CoffeeScript
3
star
12

riot-observable

Just the 'observable' function from Riot.js, as a CommonJS module
JavaScript
2
star
13

radixer

Node module for converting big numbers into shorter, URL-friendly strings
JavaScript
1
star
14

join-table

β™ŠοΈ Class for a fast collection of pairs of values with a Set-like API
JavaScript
1
star
15

is-it-bst

JavaScript function that tells you if a given date falls within British Summer Time
JavaScript
1
star
16

parse-ft-spreadsheet-key

Helper function for FT IG projects
JavaScript
1
star
17

reorient-css

Updates relative asset URLs within a string of CSS to reflect a relocation of the CSS file.
JavaScript
1
star
18

node-ruby-sass

JavaScript
1
star
19

origami-product-boilerplate

JavaScript
1
star
20

igv

JavaScript
1
star
21

h5bp-console-polyfill

Just the console.* polyfill from HTML5 Boilerplate
JavaScript
1
star
22

virtual-folder

JavaScript
1
star
23

wire

Functional build toolkit
TypeScript
1
star
24

yeoman-browserify-example

JavaScript
1
star