Format JSON
code.format_json
Overview
When you send JSON text or a file reference, we parse and re-serialize it as pretty-printed or minified output with optional key sorting and indentation. Strict mode (default) rejects comments, trailing commas, and non-numeric numbers per RFC 8259. We do not repair malformed JSON or validate against a schema — do not use this when the input must be fixed before formatting. Accepts file input via file_ref — no need to extract file content first.
Hand-formatted JSON drifts and can corrupt values. We serialize the same way every time so your pipelines stay stable.
Reliability
STRICT and deterministic for identical input and options. Parse failures surface as validation errors (PARSE_ERROR) — fix the JSON text before retrying.
Context footprint
Returns formatted JSON plus original and formatted byte counts. A successful call costs 1 execution credit.
When to use it
When input is valid JSON and you need pretty, minified, or canonical output.
When input is malformed and must be repaired first.
Powered by Jackson, the de-facto JSON engine of the Java ecosystem.
Scope
Non-goals
- Does not repair invalid JSON
- Does not validate against a schema
- Does not preserve comments in strict mode
Properties
Capabilities
Cost & billing
Flat rate per invocation
File handling
File limits
Constraints this skill applies to your input and generated files. The “Limited by” column shows the static source of each cap; none of these can be raised by upgrading your plan.
| Limit | Value | Limited by |
|---|---|---|
| Maximum size per input file | 2 MiB | Skill maximum |
How we handle your data
What this means
This skill may receive sensitive content and may return submitted, transformed, extracted, or reformatted content.
Squillify guarantees
- Runs inside Squillify
- This skill runs inside Squillify.
- Payloads are not sent to an external service by this skill.
- Squillify does not permanently store submitted payloads.
- Telemetry records metadata only, not submitted content.
- Submitted payloads are not used for training.
- Submitted payloads are not reviewed by humans.
- This skill does not target sensitive data.
- The response may contain submitted or transformed content.
Your responsibility
Squillify does not determine whether submitted content is sensitive. Your application is responsible for deciding what data it is allowed to submit. Your application is responsible for securing the response.
Input schema
| Field | Type | Required | Description |
|---|---|---|---|
| json | string | No | Inline JSON document text; omit it when file_ref is the source. |
| file_ref | string | No | Tenant-scoped managed JSON file reference; omit it when json is the source. |
| mode | string | No | Formatting mode; omit it for pretty. |
| indent | integer | No | Pretty-print spaces per level; omit it for 2. |
| sortKeys | boolean | No | Whether object keys are sorted; omit it for false. |
| ensureFinalNewline | boolean | No | Whether final newline is appended; omit it for true. |
| strict | boolean | No | Whether strict RFC 8259 parsing is used; omit it for true. |
Output schema
| Field | Type | Required | Description |
|---|---|---|---|
| ok | boolean | Yes | Successful formatting marker, always true. |
| json | string | Yes | Re-serialized JSON text. |
| valid | boolean | Yes | Successful parse marker, always true. |
| originalBytes | integer | Yes | Original UTF-8 byte count. |
| formattedBytes | integer | Yes | Formatted UTF-8 byte count. |
API contract
POST /v1/executecurl -sS -X POST "$BASE/v1/execute" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"skillKey":"code.format_json","input":{"json":"{\"a\":1}"}}'import { Squillify } from "@squillify/sdk";
const sq = new Squillify({ apiKey: process.env.SQUILLIFY_API_KEY });
const { output } = await sq.execute("code.format_json", {"sortKeys":true,"json":"{\"b\":2,\"a\":1}"});Errors
| Code | HTTP | Retryable | Description |
|---|---|---|---|
| VALIDATION_ERROR | 400 | No | The request payload failed schema validation. |
| UNAUTHORIZED | 401 | No | Missing or invalid API key. |
| SKILL_NOT_ACCESSIBLE | 403 | No | The API key is not granted access to this skill. |
| SKILL_NOT_AVAILABLE_FOR_PLAN | 403 | No | This skill is not included in your current plan. |
| PLAN_ELIGIBILITY_UNAVAILABLE | 503 | Yes | Plan eligibility could not be decided. Retry after backoff. |
| SKILL_NOT_FOUND | 404 | No | The requested skill or version does not exist. |
| TENANT_RATE_LIMITED | 429 | Yes | Request rate limit exceeded. Retry after backoff. |
| QUOTA_EXCEEDED | 429 | Yes | Plan quota exhausted. Retryable once the quota period resets. |
| EXECUTION_TIMEOUT | 504 | Yes | Execution exceeded the allowed time budget. |
Other limits
| Limit | Value |
|---|---|
| Recommended inline bytes | 32 KiB |
Limitations
- Does not repair invalid JSON
- Does not validate against a schema
- Does not preserve comments in strict mode
- Repairing malformed JSON
- JSON with comments when strict=true
How to call
POST /v1/execute (requires authentication)
{
"skillKey": "code.format_json",
"input": {
"sortKeys": true,
"json": "{\"b\":2,\"a\":1}"
}
}Examples
Pretty-print with sorted keys
{
"sortKeys": true,
"json": "{\"b\":2,\"a\":1}"
}{
"valid": true,
"ok": true,
"originalBytes": 13,
"formattedBytes": 25,
"json": "{\n \"a\" : 1,\n \"b\" : 2\n}\n"
}Minify without trailing newline
{
"json": "{\"a\":1}",
"ensureFinalNewline": false,
"mode": "minify"
}{
"valid": true,
"ok": true,
"originalBytes": 7,
"formattedBytes": 7,
"json": "{\"a\":1}"
}Recommended use cases
- Normalize agent-generated JSON before storage
- Minify JSON for transport
- Canonicalize JSON with sorted keys
Avoid for
- Repairing malformed JSON
- JSON with comments when strict=true
Related skills
Composable with
Safety & privacy
- Runs without calling any external service.
- Your payloads are never stored permanently.
- Telemetry captures metadata only — never your payload contents.
- We never train models on your payloads.
- No human reviews your payloads.