POST
/api/json-validate$0.001🛠️ JSON Validator
Validate JSON data for syntax errors and optionally validate against a JSON Schema specification. Returns detailed error messages and line/column positions for syntax errors. Supports JSON Schema Draft 7.
Request Body
Response Fields
Code Examples
cURL
bash
curl -X POST https://sparkforge.sh/api/json-validate \
-H "Content-Type: application/json" \
-H "X-PAYMENT: <x402-payment-token>" \
-d '{
"json": "{\"name\": \"Alice\", \"age\": 30}",
"schema": {
"type": "object",
"properties": {
"name": { "type": "string" },
"age": { "type": "number", "minimum": 0 }
},
"required": ["name", "age"]
}
}'Python
python
import requests, json
response = requests.post(
"https://sparkforge.sh/api/json-validate",
headers={"Content-Type": "application/json", "X-PAYMENT": "<token>"},
json={
"json": '{"name": "Alice", "age": 30}',
"schema": {"type": "object", "required": ["name", "age"]}
}
)
data = response.json()
print("Valid:", data["valid"])
if not data["valid"]:
print("Errors:", data["errors"])TypeScript / Node.js
typescript
const res = await fetch402("https://sparkforge.sh/api/json-validate", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
json: '{"name": "Alice", "age": 30}',
schema: { type: "object", required: ["name", "age"] },
}),
});
const { valid, errors, parsed } = await res.json();Example Response
json
{
"valid": true,
"errors": [],
"parsed": { "name": "Alice", "age": 30 }
}💳 Payment via x402
This endpoint costs $0.001 per call, paid in USDC on Base, Polygon, or Solana. Use the @x402/fetch library to handle payments automatically, or implement the x402 handshake manually.
bash
# Free demo mode (no payment)
curl https://sparkforge.sh/api/json-validate?demo=true
# Or try via MCP (Claude Desktop, Cursor, Windsurf)
# Add to mcp config: { "url": "https://sparkforge.sh/api/mcp" }