JSON formatter

FREE
By fpringle | Updated a month ago | Tools
Popularity

7.2 / 10

Latency

658ms

Service Level

100%

Health Check

100%

README

Format JSON

This is a very simple API with a single endpoint. Submit arbitrary, badly-formatted JSON data as the body of a POST / request, and get back beautiful, pretty-printed JSON. Yum.

$ curl -XPOST 'https://json-formatter1.p.rapidapi.com' \
  -H 'X-RapidAPI-Host: json-formatter1.p.rapidapi.com' \
  -H 'X-RapidAPI-Key: MY_API_KEY' \
  -d '{
    "x"  :  [ 1, {}
, null
], "y"
        :
    {    },"a": null  }'         # gross


{
    "a": null,
    "x": [
        1,
        {},
        null
    ],
    "y": {}
}                                # beautiful

Configuration

The formatting can be configured using query parameters.

Indentation

Tweak the representation of nesting levels using the indent parameter.

  • indent=tabs: print each level of the JSON object using tab (\t) characters.
  • indent=n: print each level using n space characters, where n is a non-negative integer.

Trailing newline

By default, the JSON data will be returned with a trailing newline character (\n). To disable this, set newline=false.

Key order

You can sort the keys of an object in alphabetical (asc) or reverse alphabetical (desc) order using the sort parameter.

For example:

$ curl -XPOST 'https://json-formatter1.p.rapidapi.com?indent=2&sort=desc' \
  -H 'X-RapidAPI-Host: json-formatter1.p.rapidapi.com' \
  -H 'X-RapidAPI-Key: MY_API_KEY' \
  -d '{
    "x"  :  [ 1, {}
, null
], "y"
        :
    {    },"a": null  }'


{
  "y": {},
  "x": [
    1,
    {},
    null
  ],
  "a": null
}
Followers: 0
API Creator:
Rapid account: Fpringle
fpringle
fpringle
Log In to Rate API
Rating: 5 - Votes: 1