The AI step
n8n Information Extractor: optional fields on fetched pages
Why Generate From JSON Example makes every field required in the n8n Information Extractor, and a JSON Schema that lets missing values come back as null.
By Caitlin Sanders, AgentScraper team · Published
This article was drafted with AI assistance from the sources listed below and edited and published by the AgentScraper team. Disclosure: the AgentScraper API, which this article mentions, is this site's own product.
- 1Filter firstOnly pages that fetched fine reach the node.
- 2Pick Define using JSON SchemaGenerate From JSON Example makes every property required.
- 3List every key in requiredEach row gets the same keys.
- 4Allow null per fieldUse a type array such as ["string", "null"].
- 5Check the resultFlag rows where every optional field is null.
Your workflow fetches a list of public pages, turns each into Markdown, and hands it to the Information Extractor node. The first ten pages work. Then one page has no price, and the schema still demands one. The node is doing what the schema told it to do. The schema just did not match real pages.
This post fixes the schema. It assumes the fetch half already works, as in the AI scraper workflow guide.
Why every field ends up required
The Information Extractor offers three choices under "Schema Type": "From Attribute Descriptions", "Generate From JSON Example" and "Define using JSON Schema". In a new node, the default is "From Attribute Descriptions".
"Generate From JSON Example" is the quick one. You paste a sample object. The node keeps the property names and their types, ignores the values, and treats every field as mandatory.
What you see: a notice under the example field that reads "All properties will be required. To make them optional, use the 'JSON Schema' schema type instead". In the node source, that notice is tied to node version 1.2 and later.
On a product page or an event page, that is rarely true. One page has a date and no price. Another has a price and no registration link. A schema that requires all three asks the model for values that are not in the text.
Option 1: From Attribute Descriptions
Each attribute has four fields: "Name", "Type", "Description" and "Required". "Type" offers Boolean, Date, Number and String. "Required" is off by default.
- Click "Add Attribute" once per field.
- Write the "Description" as an instruction, for example "Ticket price as a number, without currency sign".
- Turn on "Required" only for fields every page has, such as the title.
What you see: a flat list of fields, with no nesting. That is fine for four values per page. It gets awkward once you want a list of objects, such as several dates per event.
Option 2: Define using JSON Schema with null
In JSON Schema, a property listed under properties is not required unless you name it in the required array. You could leave optional fields out of required. Then the key is simply missing from some rows, and your sheet or table gets columns that come and go.
The steadier pattern: list every key in required, and give each optional field a type array that includes null. JSON Schema accepts type as an array, and null is one of its basic types.
- Set "Schema Type" to "Define using JSON Schema".
- Paste this into "Input Schema":
{
"type": "object",
"properties": {
"title": { "type": "string", "description": "Event title as shown on the page" },
"start_date": { "type": ["string", "null"], "description": "Start date as YYYY-MM-DD, or null if the page has none" },
"price": { "type": ["number", "null"], "description": "Lowest ticket price as a number, or null if the page shows none" },
"registration_url": { "type": ["string", "null"], "description": "Registration link, or null if the page has none" }
},
"required": ["title", "start_date", "price", "registration_url"]
}
- Point "Text" at the field that holds the page's Markdown.
- Run the node on one page you know has gaps, for example
https://example.com/events/spring-meetup.
What to expect: the schema asks for all four keys on every item and allows null wherever the page has no value.
One limit to know: the "Input Schema" hint says that $refs syntax is not supported, so write nested objects out in full.
Option 3: keep the example, but only for full pages
"Generate From JSON Example" is still fine when every page really has every field, for example your own product pages built from one template. Use it there, and use the JSON Schema everywhere else.
Where items go wrong
| What you see | Likely cause | Fix |
|---|---|---|
| A field the page lacks is still required | "Generate From JSON Example" made the field required | Switch to "Define using JSON Schema" with a null type |
| Columns appear and disappear between rows | Optional fields are left out of required | List every key in required, allow null |
| The model invents a plausible price | The description does not say what to do when the value is missing | Add "or null if the page shows none" to the description |
Every field is null | The page was an error page, a cookie wall or empty Markdown | Filter failed fetches before the node, flag all-null rows after it |
What this means for your workflow
- The fetch step and the extraction step fail for different reasons. Keep them apart, and filter failed pages before the model sees them, as in the Text Classifier walkthrough.
nullis an answer. It says "the page did not have it", which is more useful than a guessed value.- If your fetch step is AgentScraper API, it returns the page as Markdown, so this node is where extraction and validation happen. The HTTP Request settings for that step are in the No-code recipes.
Frequently asked questions
Why does the n8n Information Extractor demand fields the page does not have?
With the schema type Generate From JSON Example, every property in the generated schema is required. The node even shows the notice that all properties will be required. If the page does not contain a value, the model has nothing valid to return for that field.
How do I make a field optional in the n8n Information Extractor?
Either switch the schema type to Define using JSON Schema and leave the field out of the required array, or use From Attribute Descriptions, where each attribute has a Required toggle that is off by default.
Should a missing field be absent or null?
For tables and sheets, null is easier. List every key in required and give optional fields a type array that includes null, so every row has the same keys and null means the page did not have the value.
Does the Information Extractor support $ref in a JSON Schema?
No. The Input Schema field's hint says that $refs syntax is currently not supported, so write nested objects out in full.
Sources
- Information Extractor node documentation (Documentation)
- InformationExtractor.node.ts (n8n source) (Documentation)
- descriptions.ts: shared schema fields (n8n source) (Documentation)
- JSON Schema reference: object (Documentation)
- JSON Schema reference: type (Documentation)