OpenAI Strict JSON Schema Generator for Structured Outputs

1. Live Regex Tester

Paste how your sales reps enter data.
Prepended if the number lacks a country code.
Valid E.164 Format
+15551234567

2. Copy-Paste Automation Logic

If you are building B2B workflows using Make.com, n8n, or custom Python scripts, you know the pain of LLM hallucinations. When an AI returns a string instead of a number, or randomly wraps your JSON in markdown code blocks (```json), your entire automation breaks.

In August 2024, OpenAI introduced Structured Outputs (Strict JSON Mode), which guarantees that the model will exactly match the schema you provide. However, OpenAI’s API requires a highly specific, nested JSON Schema format. Use the visual generator above to build your schema, ensure additionalProperties is set to false, and copy-paste it directly into your API call.

Why GPT-4o Hallucinates Without Strict JSON Schema

Historically, developers used prompt engineering to force JSON out of LLMs (e.g., “Return your answer as a JSON object and do not include any other text”).

This method is fragile. If the LLM decides to be “helpful” and appends “Here is your JSON:” at the top of the payload, your automation’s JSON parser will instantly throw a 400 Bad Request error.

By passing the response_format object with strict: true (which our generator builds for you), OpenAI uses a technique called constrained decoding. The API physically prevents the LLM from generating tokens that violate your schema structure. It is impossible for the model to omit a required key or hallucinate an unapproved data type.

The Difference Between json_object Mode and Structured Outputs

If you look at the OpenAI API documentation, you will see two different ways to request JSON. It is critical for Ops Engineers to know the difference:

  1. JSON Mode ({ "type": "json_object" }): This older method guarantees the output will be valid JSON, but it does not guarantee the structure. The AI might give you valid JSON, but it could invent its own keys or change your nested arrays into flat strings.
  2. Structured Outputs (Strict JSON Schema): This new method (generated by the tool above) guarantees both valid JSON and exact structural adherence. It requires you to define every single property, mark all properties as required, and set additionalProperties: false.

How to Pass This Schema into a Make.com or n8n HTTP Node

Once you have copied the JSON from the generator above, you need to inject it into your workflow automation tool.

If you are using a raw HTTP Request Node to hit the https://api.openai.com/v1/chat/completions endpoint, your JSON body should look like this:

Json
{
  "model": "gpt-4o",
  "messages": [
    {
      "role": "system",
      "content": "You are a data extraction assistant."
    },
    {
      "role": "user",
      "content": "Extract the lead data from this email..."
    }
  ],
  "response_format": [PASTE_THE_GENERATED_SCHEMA_HERE]
}

Handling Nested Arrays and Objects in LLM Outputs

Our basic generator above covers 90% of B2B automation use cases (extracting strings, numbers, and booleans).

However, if you are extracting line items from a PDF invoice or scraping a list of competitors from a website, you will need to return an Array of Objects. To do this, you must define the type: "array" in your schema and then define the nested items object. Remember that even inside nested arrays, OpenAI requires additionalProperties: false to be explicitly declared on every single object.


Need to connect OpenAI to your CRM without writing code? Don’t waste time fighting API documentation. Download our library of pre-tested, strict-JSON n8n and Make.com workflow blueprints.