Structured Data Fixer — repair & normalize messy JSON/CSV/text avatar

Structured Data Fixer — repair & normalize messy JSON/CSV/text

Under maintenance

Pricing

Pay per usage

Go to Apify Store
Structured Data Fixer — repair & normalize messy JSON/CSV/text

Structured Data Fixer — repair & normalize messy JSON/CSV/text

Under maintenance

Repair LLM-broken JSON, strip invisible characters, dedupe rows, coerce types and validate against a JSON Schema. Deterministic rules only, no API keys, no external packages.

Pricing

Pay per usage

Rating

0.0

(0)

Developer

byd666

byd666

Maintained by Community

Actor stats

0

Bookmarked

1

Total users

0

Monthly active users

13 days ago

Last modified

Categories

Features

Limited permissions

Share

Structured Data Fixer

Repair and normalize messy JSON, CSV, and plain text in one pass. Deterministic rules only — no LLM calls, no API keys, no network access. Zero npm dependencies: pure Node stdlib plus the Apify runtime that ships in the official base image (no npm install).

Why

LLM output and exported data are routinely almost valid: single-quoted JSON, trailing commas, Markdown fences, unquoted keys, smart quotes, invisible characters, duplicate rows, numbers stored as strings. This Actor cleans that up and tells you exactly what it changed.

Use cases

  • Clean LLM output before JSON.parse (fences, single quotes, trailing commas, unquoted keys).
  • Normalize exported CSV/log rows: invisible chars, whitespace, NFKC, exact-duplicate rows.
  • Validate a payload against a JSON Schema and coerce "30" → 30 where the schema says so.

Input

FieldTypeDescription
contentstring (required)Raw content, max 1 MB (larger input returns INPUT_TOO_LARGE).
contentTypeauto / json / csv / textDefault auto (detect from content).
jsonSchemastringOptional JSON Schema; enables validation + safe type coercion.
optionsobjectrepairJson, stripInvisible, normalizeWhitespace, nfkc, dedupeRows, coerceTypes — all default true.
maxPreviewItemsinteger0–50, default 5.

Output (dataset)

One item per run:

FieldDescription
okfalse only for fatal conditions (INPUT_TOO_LARGE, unparseable JSON, invalid schema)
errorerror code when ok=false
detectedTypejson / csv / text / unknown
cleanedTextcleaned content, ready to parse or save
datastructured result (object/array or {rows} / {lines})
issues[]what was fixed and why (JSON_SINGLE_QUOTES, JSON_TRAILING_COMMA, JSON_MARKDOWN_FENCE, JSON_UNQUOTED_KEY, INVISIBLE_CHARS, SMART_QUOTES, WHITESPACE, NFKC_NORMALIZED, DEDUPED_ROWS, TYPE_COERCED, SCHEMA_VIOLATION, JSON_PARSE_FAILED, SCHEMA_INVALID)
warnings[]explicitly lists heuristic guesses (e.g. "single quotes were interpreted as JSON string delimiters"). Read these before trusting the output.
statsinputBytes / outputBytes / removedInvisible / dedupedRows / repairedJson / coercedFields
previewfirst N structured rows

Example

Input:

content: "```json\n{'name': 'Alice', 'age': '30', 'tags': ['a','b',], city: 'Guilin',}\n```"

Result: ok=true, repairedJson=true, cleanedText={"name":"Alice","age":"30","tags":["a","b"],"city":"Guilin"} with issues JSON_MARKDOWN_FENCE, JSON_SINGLE_QUOTES, JSON_TRAILING_COMMA, JSON_UNQUOTED_KEY and one warning per heuristic.

Honesty notes

  • The Actor does not invent missing data. Unparseable JSON stays unparseable (ok=false, JSON_PARSE_FAILED).
  • Heuristics (single quotes as JSON delimiters, unquoted keys, fence stripping, smart-quote normalization, dedupe) are deterministic but assumptions; every one is listed in warnings[].
  • CSV handling targets standard RFC4180; exotic dialects may need review.
  • No PDF/OCR support (separate Actors cover that).

Local run

node main.js   # reads apify_storage/key_value_stores/default/INPUT.json or ./INPUT.json

Sample output

{
"ok": true,
"error": null,
"detectedType": "json",
"cleanedText": "{\"name\":\"Alice\",\"age\":\"30\",\"tags\":[\"a\",\"b\"],\"city\":\"Guilin\"}",
"data": {
"name": "Alice",
"age": "30",
"tags": [
"a",
"b"
],
"city": "Guilin"
},
"issues": [
{
"code": "JSON_MARKDOWN_FENCE",
"message": "markdown code fence stripped"
},
{
"code": "JSON_SINGLE_QUOTES",
"message": "single-quoted strings converted to double quotes"
},
{
"code": "JSON_TRAILING_COMMA",
"message": "trailing commas removed"
},
{
"code": "JSON_UNQUOTED_KEY",
"message": "unquoted object keys quoted"
}
],
"warnings": [
"A Markdown code fence was stripped before parsing (heuristic).",
"Single quotes were interpreted as JSON string delimiters (heuristic).",
"Unquoted keys were assumed to be property names (heuristic).",
"Content type was auto-detected as json (starts with { or [); set contentType to make it explicit."
],
"stats": {
"inputBytes": 79,
"outputBytes": 60,
"removedInvisible": 0,
"dedupedRows": 0,
"repairedJson": true,
"coercedFields": 0
},
"preview": [
{
"name": "Alice",
"age": "30",
"tags": [
"a",
"b"
],
"city": "Guilin"
}
]
}

Privacy & data

  • Runs entirely inside the Actor container: no network calls, no external APIs, no data leaves the run except the dataset you can export.
  • The input is processed in memory; only the single output item is written to the dataset.
  • No Apify Proxy / no full permissions needed (limited permissions).

Permissions

Limited permissions. The Actor only reads its input and writes its dataset item; it does not access the internet or your other storages.

Pricing

Free (pay-per-usage free tier). Pay-per-event pricing may be enabled later. Up to 1 MB input per run; larger inputs return INPUT_TOO_LARGE without processing.

License: MIT