Skip to content

JSON Cleaner

JSON Cleaner receives a text that should be in JSON format, like the one a model returns when you ask for structured data, and fixes it so it is valid JSON: it removes extra text, closes braces and fixes quotes.

When to use it

  • A model returns JSON data with some error and the next component fails.
  • You want to make sure a model’s answer can be read as data.

Configuration

FieldWhat it does
JSON String (required)The text to clean.
Remove Control CharactersRemoves invisible characters that can break the format. Off by default.
Normalize UnicodeUnifies how special characters, such as accents, are written. Off by default.
Validate JSONChecks the result is valid JSON and fails if it is not. Off by default.

Output

The Cleaned JSON String output is the fixed text.

Example

A model extracts each invoice’s number, date and amount in JSON, but sometimes adds a sentence before it.

  1. Connect the model’s answer to JSON String and turn on Validate JSON.
  2. Connect Cleaned JSON String to the component that stores the data.