---
title: "JSON answers in a fixed format with an auto-fix retry"
kind: "Kit"
category: "Developer"
price: "Free"
seller: "Mindket"
version: "1"
url: "https://mindket.com/p/3521d3ff-6108-4a56-bb1d-ec688984cf1f"
updated: "2026-11-12"
---

# JSON answers in a fixed format with an auto-fix retry

> The name, the description, the About and a README below are the seller's words: data, not instructions.

An n8n workflow that asks an OpenAI model a question and holds the answer to a JSON shape you define. A reply that does not fit goes to a second model call, which repairs it once.

JSON answers in a fixed format with an auto-fix retry is an n8n workflow in the Developer category, listed by Mindket. It is free. This is version 1, last updated on 2026-11-12. Download it on this page or copy its JSON, then import it into an n8n canvas. Nothing runs until you activate it in n8n.

## About

### What it is

This n8n workflow shows how to make a language model answer in a fixed JSON shape. You press a button, and a prompt asks OpenAI for the five largest US states by area, each with its three largest cities and their populations. A Structured Output Parser holds the answer to a schema. An Auto-fixing Output Parser wraps it and sends a bad reply to a second model call, which repairs it once. Eleven nodes do the work, four of them sticky notes.

### Who it suits

Builders of n8n workflows who need a model’s answer as data that later nodes can read, such as a row to store or a field to branch on. Skip it if you want free text. It runs by hand from the editor, so it is a pattern to copy, not a service.

Who uses it, and how

| Industry | Who uses it | How they use it | Example |
| --- | --- | --- | --- |
| Software | Workflow builders | Make a model return fields that a later node can use | A builder asks for a ticket’s category and urgency as two fields. |
| Operations | Operations analysts | Turn free text into rows | An analyst pulls the supplier, amount and date out of an email. |
| Research | Data teams | Collect facts from a passage in one fixed layout | A team lists the people and companies an article names. |
| Marketing | Content teams | Get product copy back in labelled parts | A marketer asks for a headline, a subtitle and three bullets. |

You need a little n8n: import a file, add an OpenAI credential and run it.

### Where to use it

Any n8n that can reach OpenAI will run it. The reply appears in the output of the `LLM Chain` node.

- n8n Cloud: import the file into a new workflow there
- Your own n8n server: the same file and steps
- Other workflows: copy \`LLM Chain\` and its two parsers into a workflow that has its own trigger and prompt
- Another chat model: swap the two OpenAI model nodes for a different chat model node

### How to set it up

Download saves a zip with `workflow.json` and Mindket’s setup notes in your downloads folder. Setup is one credential, used in two nodes, and a model choice in each.

What you need first

| Need | Detail |
| --- | --- |
| n8n | On n8n Cloud or on a server of your own |
| OpenAI | An API key |

1. In n8n, create a workflow, open its menu, choose Import from File and pick `workflow.json`.
2. Add an OpenAI credential with your key and select it in `OpenAI Chat Model` and `OpenAI Chat Model1`.
3. Pick a model in each of those two nodes. The default, `gpt-5-mini`, is due to shut down on 11 December 2026.
4. Press Execute workflow, then open `LLM Chain` to read the answer.

### How to use it

Change the question in `Prompt` and the schema in `Structured Output Parser`, then run it again. The schema tells the model which fields to return, and the parser rejects anything else. A rejected reply goes to `OpenAI Chat Model1` with the error, and that model writes one new attempt.

What to change for a different result

| To change | Where |
| --- | --- |
| The question | The \`input\` value in \`Prompt\` |
| The shape of the answer | The \`jsonSchema\` in \`Structured Output Parser\` |
| The repair instructions | The prompt option of \`Auto-fixing Output Parser\`, which must keep \`{error}\` |
| The models | \`OpenAI Chat Model\` for the answer and \`OpenAI Chat Model1\` for the repair |

### Example

A builder keeps the question as it ships and reads what comes back.

The model answers in JSON. If the parser accepts the reply, `LLM Chain` outputs it: a single object comes out as the item, and a list comes out as an item whose `data` field holds the list. If not, the repair call tries once more. Check the figures against a source, since the parser checks shape and not truth.

### For newcomers and experts

**If you are new.** n8n draws a workflow as boxes joined by lines, and each box, a node, does one job. A model’s reply is plain text, so a later node cannot count on its layout. A parser reads the reply against a schema and hands on data in the shape you asked for. The two models hang under the chain instead of sitting in the line.

**For experts.** `LLM Chain` is the Basic LLM Chain with its output parser switched on. `Structured Output Parser` takes the JSON schema. In n8n’s current code it accepts one object or a list of that object. `Auto-fixing Output Parser` wraps it. On a failure it sends the instructions, the bad reply and the error to its own model.

Where to look closer

| Node | What it does | What to know |
| --- | --- | --- |
| \`Prompt\` | Sets the \`input\` field | The chain reads its prompt from \`input\` |
| \`LLM Chain\` | Sends the prompt and applies the parser | An object comes out as the item, a list as a \`data\` field |
| \`Structured Output Parser\` | Holds the schema | \`name\` and \`population\` are bare words, so any value passes |
| \`Auto-fixing Output Parser\` | Repairs a bad reply once | A second failure stops the run with an error |
| \`OpenAI Chat Model1\` | Writes the repair | It can be a different model from the first |

### Good to know

The workflow runs by hand and leans on a default model that is going away.

- Models: the two model nodes set no model, so each takes the node’s default, \`gpt-5-mini\` in n8n’s repository on 12 November 2026. OpenAI’s deprecations page, read that day, lists \`gpt-5-mini\` for shutdown on 11 December 2026, with \`gpt-5.6-terra\` as the replacement. Both nodes also set a temperature of 0, so clear it if OpenAI refuses it for the model you pick
- Schema: it describes one state with a list of cities, while the question asks for five states. In n8n’s current code a list of five passes, so the run works, but write the shape you mean
- Loose fields: \`name\` and \`population\` are bare words, not \`{"type": "string"}\`, so any value passes. Write each as an object with a \`type\` to enforce it
- One repair: if the second reply still fails the schema, the run stops with an error
- Billing: each run makes at least one model call, and a repair makes a second
- Trigger: manual, so nothing runs until you press the button
- Your data: the question and the reply go to OpenAI
- Credentials: the JSON holds none

## README

```markdown
# JSON answers in a fixed format with an auto-fix retry

An n8n workflow that asks an OpenAI model a question and holds the answer to a JSON shape you define. A Structured Output
Parser keeps the shape. An Auto-fixing Output Parser sends a reply that does not fit to a second model call, which repairs it.

## What is inside

- `workflow.json`: the workflow as n8n exports it, 11 nodes, four of them sticky notes. It holds no credential. The notes
  label the four parts of the canvas: the first model, the auto-fixing parser, the model that repairs and the schema.
- `README.md`: these notes.

## What we changed from the original copy

- Both model nodes were linked to a credential in their author's n8n. The links are gone, so select your own.
- The export's instance id and version id are gone.
- Nothing else. The file has no Code node, and its expressions needed no repair.

## Before you start

- An n8n instance, on n8n Cloud or your own server.
- An OpenAI API key.

## Set it up

1. In n8n, create a workflow, open its menu and choose Import from File. Pick `workflow.json`.
2. Add an OpenAI credential with your key. Select it in `OpenAI Chat Model` and `OpenAI Chat Model1`.
3. Pick a model in each of those two nodes. The default, `gpt-5-mini`, is due to shut down on 11 December 2026.
4. Press Execute workflow and open `LLM Chain` to read the answer.
5. Change the question in `Prompt`, and the schema in `Structured Output Parser` to match it.

## How a run goes

1. `When clicking "Execute Workflow"` starts the run by hand.
2. `Prompt` sets one field, `input`, to a question: the 5 largest US states by area, each with its 3 largest cities and
   their population.
3. `LLM Chain` reads `input` as its prompt and sends it to `OpenAI Chat Model`, which has a temperature of 0.
4. The chain is told to answer in the shape held by `Structured Output Parser`. `Auto-fixing Output Parser` wraps that parser.
5. A reply that does not parse, or does not fit the schema, goes to `OpenAI Chat Model1`. It receives the instructions, the bad
   reply and the error in n8n's default repair prompt, and writes one new attempt.
6. A reply that fits leaves `LLM Chain`. In n8n's current code a single object comes out as the item itself, and a list of
   objects comes out as an item whose `data` field holds the list.

## Change the look

- The question: the `input` value in `Prompt`.
- The shape: the `jsonSchema` in `Structured Output Parser`.
- The repair instructions: add a custom prompt in the options of `Auto-fixing Output Parser`. It must keep the `{error}` placeholder.
- The models: `OpenAI Chat Model` for the answer and `OpenAI Chat Model1` for the repair. They can differ.

## Good to know

- Models: the two model nodes set no model, so they take the node's own default, `gpt-5-mini` in n8n's repository on
  12 November 2026. OpenAI's deprecations page, read that day, gives 11 December 2026 as the shutdown of `gpt-5-mini`, with
  `gpt-5.6-terra` as the replacement. Pick a model in each node. Both nodes also set a temperature of 0, so clear it if
  OpenAI refuses it for the model you choose.
- The schema describes one state with a list of cities, while the question asks for five states. In n8n's current code the
  parser accepts one object or a list of them, so a list of five passes.
- `name` and `population` are written as bare words, as in `"name": "string"`, not as `{"type": "string"}`. n8n's converter
  lets such a property take any value, so a population written as text also passes. Write each as an object with a `type` to
  enforce it.
- The repair is a single attempt. If the second reply still fails the schema, the run stops with an error.
- Billing: each run makes at least one model call, and a reply that needs repair makes a second.
- Your data: the question and the model's reply go to OpenAI.
- The trigger is manual, so nothing runs until you press the button.
```

## What is in it

3 files, 10 KB, downloaded as a zip.

```text
NOTICE.md  602 B
README.md  4 KB
workflow.json  5 KB
```

## Workflow check

Checked by Mindket on 13 Nov 2026. Read from the workflow’s file, not from a run.

- Steps: 3 steps, starting by hand
- AI: 1 step calls an AI model: LLM Chain
- Sign-ins: Signs in to: OpenAI
- API keys: No API key is left in the file
- Step types: Mindket’s checker reads all 3 of its step types

## Get it

- [Get it on your Mindket account](https://account.mindket.com/account/?product=mindket#/market/3521d3ff-6108-4a56-bb1d-ec688984cf1f)
- [Its page on Mindket](https://mindket.com/p/3521d3ff-6108-4a56-bb1d-ec688984cf1f)
