Gemini JSON Extractor
Tell Gemini what fields you want, get JSON back
- extracted_json
- formatted_output
Extraction without writing a schema
GeminiStructuredOutput is the powerful route, but sometimes a full JSON Schema is overkill. You just want the model to pull a few named fields out of some text: a title, an author, a list of keywords. That's the whole job of GeminiJSONExtractor - you declare fields in a dead-simple name: type format and it returns clean JSON. It's the middle ground between a free-form text call and a schema-constrained one, and for everyday data wrangling it's often the right amount of tool.
It lives in the same jqy-yo/comfyui-gemini-nodes pack as the rest of the Gemini nodes and shares their DNA: a prompt, a key, a model, JSON out.
How it works
You feed it two things: the text to analyze and a field list. Field definitions use a tiny format:
title: string
author: string
word_count: integer
tags: string[]
is_featured: boolean
category: string?
Supported types are string, number/float, integer/int, boolean/bool, and arrays via type[]. A ? suffix marks the field optional. The node then instructs the model to extract exactly those fields from the input and return them as JSON - the same schema-validation trick as Structured Output, minus the schema-writing ceremony.
Inputs that matter
- extract_fields - the field definition block above. This is the heart of the node; get the field names right and the rest takes care of itself.
- input_text - the text to extract from. Can be combined with the prompt if you want to do both.
- prompt - extraction instructions. Defaults to "Extract the requested information from the provided text. Be accurate and concise."
- temperature - default is 0.3, and that's the right instinct: low temperature keeps extraction accurate. Extraction is a task where creativity is your enemy.
- system_instructions - override the default extraction guidance if you have specific rules (language, format of dates, etc.).
Outputs are extracted_json (raw JSON - feed it straight into GeminiFieldExtractor or GeminiJSONParser downstream) and formatted_output (a human-readable version with field labels, handy for a preview node).
Install
Part of the standard pack install:
cd ComfyUI/custom_nodes
git clone https://github.com/jqy-yo/comfyui-gemini-nodes
cd comfyui-gemini-nodes
pip install -r requirements.txt
Or grab "ComfyUI Gemini Nodes" via ComfyUI Manager. Key goes in the api_key field or the GOOGLE_API_KEY env var. Restart ComfyUI afterward.
Where people get burned
The predictable failure is a field name that doesn't match anything in the text - the model will happily invent a value, so give optional fields the ? suffix and don't demand data that isn't there. Use clear, descriptive field names; "category: string[]" beats "stuff: string[]" every time. And remember this node does cost an API call - it's not a local parser. If the text you're working with is already JSON, you don't need an LLM at all; that's what GeminiJSONParser and GeminiFieldExtractor are for, and they're free. Use this node when the text is messy prose and a regex would be a weekend project.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | β | |
| api_key | STRING | β | |
| model | STRING | gemini-2.0-flash | β |
| extract_fields | STRING | title: string summary: string keywords: string[] | β |
| temperature | FLOAT | 0.300β1 | β |
| seed | INT | 00β2147483647 | β |
| input_textopt | STRING | β | |
| system_instructionsopt | STRING | Extract the requested information from the provided text. Be accurate and concise. | β |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| extracted_json | STRING | β |
| formatted_output | STRING | β |