JSON API Documentation

Programmatic access to JSON validation and formatting tools

Getting Started

Our JSON API provides endpoints for validating, formatting, and comparing JSON documents. All endpoints accept and return JSON data.

Base URL

https://jsonlint.pro/api/json

Authentication

Currently, the API is open and does not require authentication. However, rate limiting may be implemented in the future.

POST /validate

Validate JSON

Validates a JSON document and returns the parsed data if valid.

Request

{
    "json": "{\"name\":\"John\",\"age\":30}"
}

Response (Success)

{
    "status": "success",
    "message": "Valid JSON",
    "data": {
        "name": "John",
        "age": 30
    }
}

Response (Error)

{
    "status": "error",
    "message": "Invalid JSON",
    "error": "Syntax error"
}
POST /validate-schema

Validate JSON Against Schema

Validates a JSON document against a JSON Schema.

Request

{
    "json": "{\"name\":\"John\",\"age\":30}",
    "schema": "{
        \"type\":\"object\",
        \"properties\":{
            \"name\":{\"type\":\"string\"},
            \"age\":{\"type\":\"number\"}
        },
        \"required\":[\"name\",\"age\"]
    }"
}

Response (Success)

{
    "status": "success",
    "message": "JSON is valid according to the schema",
    "data": {
        "name": "John",
        "age": 30
    }
}

Response (Error)

{
    "status": "error",
    "message": "JSON does not match schema",
    "errors": [
        {
            "instancePath": "/age",
            "message": "must be a number"
        }
    ]
}
POST /format

Format JSON

Formats a JSON document with specified indentation.

Request

{
    "json": "{\"name\":\"John\",\"age\":30}",
    "indent": 2
}

Response (Success)

{
    "status": "success",
    "message": "JSON formatted successfully",
    "data": "{
  \"name\": \"John\",
  \"age\": 30
}"
}
POST /compare

Compare JSON Documents

Compares two JSON documents and returns the differences.

Request

{
    "json1": "{\"name\":\"John\",\"age\":30}",
    "json2": "{\"name\":\"John\",\"age\":31}"
}

Response (Success)

{
    "status": "success",
    "message": "JSON comparison completed",
    "data": {
        "are_equal": false,
        "differences": [
            {
                "path": ["age"],
                "old_value": 30,
                "new_value": 31
            }
        ]
    }
}

Example Usage

Here's an example of how to use the API with cURL:

# Validate JSON
curl -X POST https://jsonlint.pro/api/json/validate \
    -H "Content-Type: application/json" \
    -d '{"json":"{\"name\":\"John\",\"age\":30}"}'

# Format JSON
curl -X POST https://jsonlint.pro/api/json/format \
    -H "Content-Type: application/json" \
    -d '{"json":"{\"name\":\"John\",\"age\":30}","indent":2}'

# Compare JSON
curl -X POST https://jsonlint.pro/api/json/compare \
    -H "Content-Type: application/json" \
    -d '{"json1":"{\"name\":\"John\",\"age\":30}","json2":"{\"name\":\"John\",\"age\":31}"}'
Website hosted by HostSlim