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
The formatting can be configured using query parameters.
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.By default, the JSON data will be returned with a trailing newline character (\n
). To disable this, set newline=false
.
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
}