🥞
Glif Docs/Guide
  • Getting Started
    • 👋What is Glif?
    • 💡What can I do with a glif?
      • 🏃Run a glif
      • 🔌Build a glif
      • 🔀Remix a glif
      • 🗣️Comment on a glif
      • 🔳Embed a glif
    • ⚒️How do I build a glif?
      • 📽️Video tutorial: Building a simple image generator
      • 🟰Using variables
    • ⚙️Profile Settings
    • 🪙Credits and Payments
    • ❓FAQs
  • Blocks
    • 🙋Inputs
      • ✍️Text Input Block
      • 🖼️Image Input Block
      • 📋Multipick Block
    • 🪄Generators
      • 📃Text Block
      • 🖼️Image Block
      • ➡️Image to Text Block
        • Florence2Sam2Segmenter
    • 🧰Tools
      • 🔀Text Combiner Block
      • 🔬JSON Extractor Block
    • 💅Styling
      • 🎨HTML Block
      • 🖼️Canvas Block
    • 🧑‍🔬Advanced/Experimental
      • 🎙️Audio Input Block
      • ↔️Glif Block
      • 🌐Web Fetcher Block
      • 🔊Audio Spell
      • 🧱ComfyUI Block
      • 📡Audio to Text Block
      • 🎥Video Input Block
      • 🔧JSON Repair Block
  • Apps
    • 🎨Glif It! Browser Extension
  • Glif University
    • 🎥Video Tutorials
      • 🐲How To: D&D Character Sheet Generator
      • 🧠How To: Expanding Brain Meme Generator
      • 🦑How To: Occult Memelord Generator
      • 🥸How To: InstantID Portrait Restyle Glif
      • 🕺How To: Style and Pose a Character with InstantID + Controlnet
      • 😱How To: Create a Simple Cartoon Portrait Animation Glif (LivePortrait + Custom Blocks)
      • 👗How to Create a Clothing Restyler App (IP Adapter, ControlNet + GPT Vision)
      • 🤡How to Create a 4+ Panel Storyboard/Comic (Flux Schnell)
      • 🎂How to Create a Recipe Generator with Accompanying Pictures
      • How to Use JasperAI Depth Controlnet on Flux Dev
      • 🦸‍♂️How to Make a Consistent Comic Panel Generator
    • 🧑‍🏫Prompt Engineering 101
    • 🖼️ControlNet
    • 📚AI Glossary
  • API - for Developers
    • ⚡Running glifs via the API
    • 🤖Using AI Assistants to build with the Glif API
    • 📙Reading & writing data via the API
    • 🗾Glif Graph JSON Schema
    • 📫Embed player & custom webpages
    • 📫Sample code
    • ❓What can I make with the Glif API?
      • Browser Extensions
      • Discord Bots
      • Games
      • Social Media Bots
      • Experimental Projects
  • Policies
    • 👨‍👩‍👧‍👦Community Guidelines
  • Programs
    • 🖼️Loradex Trainer Program
  • Community Resources
    • 🧑‍🤝‍🧑Resources Created by Glif Community Members
  • Contact Us
    • 📣Send us your feedback
    • 🚔Information for law enforcement
Powered by GitBook
On this page
  • Input JSON
  • Features
  • Output
  • Example
  1. Blocks
  2. Advanced/Experimental

JSON Repair Block

Repair and fix invalid JSON documents

PreviousVideo Input BlockNextGlif It! Browser Extension

Last updated 1 month ago

Advanced/Experimental or to report issues

Automatically repair and fix invalid JSON using the library. This block can handle various JSON formatting issues and convert them into valid JSON.

You may be generating JSON from an unreliable source like an LLM or an external API, which might output invalid or poorly formatted JSON. Adding this block to your workflow ensures you end up with valid JSON. If the block can't repair your input then it will throw an error.

Input JSON

Paste or type your input into the "JSONish string" input, or use a variable from another block.

Features

The JSON Repair block uses the jsonrepair library to fix the following issues:

  • Add missing quotes around keys

  • Add missing escape characters

  • Add missing commas

  • Add missing closing brackets

  • Repair truncated JSON

  • Replace single quotes with double quotes

  • Replace special quote characters like "..." with regular double quotes

  • Replace special white space characters with regular spaces

  • Replace Python constants None, True, and False with null, true, and false

  • Strip trailing commas

  • Strip comments like /* ... */ and // ...

  • Strip ellipsis in arrays and objects like [1, 2, 3, ...]

  • Strip JSONP notation like callback({ ... })

  • Strip escape characters from an escaped string like {\"stringified\": \"content\"}

  • Strip MongoDB data types like NumberLong(2) and ISODate("2012-12-19T06:01:17.171Z")

  • Concatenate strings like "long text" + "more text on next line"

  • Turn newline delimited JSON into a valid JSON array

Output

The block will output the repaired JSON.

Example

Input (invalid JSON):

{
  name: 'John',
  age: 30,
  active: True,
  tags: ['dev', 'ops', ...],
  // This is a comment
  description: "long text" + "more text"
}

Output (valid JSON):

{
  "name": "John",
  "age": 30,
  "active": true,
  "tags": ["dev", "ops"],
  "description": "long textmore text"
}
🧑‍🔬
🔧
Contact us
join Discord
jsonrepair