JSON Parser¶
Class: JSONParserBlockV1
Source: inference.core.workflows.core_steps.formatters.json_parser.v1.JSONParserBlockV1
Parse JSON strings (raw JSON or JSON wrapped in Markdown code blocks) into structured data by extracting specified fields and exposing them as individual outputs, enabling JSON parsing, LLM/VLM output processing, structured data extraction, and configuration parsing workflows where JSON strings need to be converted into usable workflow data.
How This Block Works¶
This block parses JSON strings and extracts specified fields as individual outputs. The block:
- Receives a JSON string input (typically from LLM/VLM blocks or workflow inputs)
- Detects and extracts JSON content:
Handles Markdown-wrapped JSON:
- Searches for JSON wrapped in Markdown code blocks (json ...)
- This format is very common in LLM/VLM responses (e.g., GPT responses)
- If multiple markdown JSON blocks are found, only the first block is parsed
- Extracts the JSON content from within the markdown tags
Handles raw JSON strings:
- If no markdown blocks are found, attempts to parse the entire string as JSON
- Supports standard JSON format strings
3. Parses JSON content:
- Uses Python's JSON parser to convert the string into a JSON object/dictionary
- Handles parsing errors gracefully (returns None for all fields if parsing fails)
4. Extracts expected fields:
- Retrieves values for each field specified in expected_fields parameter
- For each expected field, looks up the corresponding key in the parsed JSON
- Returns the field value (or None if the field is missing)
5. Sets error status:
- error_status is set to True if at least one expected field cannot be retrieved from the parsed JSON
- error_status is set to False if all expected fields are found (even if multiple markdown blocks exist, only first is parsed)
- Error status is always included as an output, allowing downstream blocks to check parsing success
6. Exposes fields as outputs:
- Each field in expected_fields becomes a separate output with the field name
- Field values are extracted from the parsed JSON and made available as outputs
- Missing fields are set to None
- All outputs can be referenced using $steps.block_name.field_name syntax
7. Returns parsed data:
- Outputs include: error_status (boolean) and all expected fields
- Fields contain the extracted values from the JSON (or None if missing)
- Outputs can be used in subsequent workflow steps
The block is particularly useful for processing LLM/VLM outputs that return JSON, extracting structured configuration from JSON strings, and parsing JSON responses into workflow-usable data. It handles the common case where LLMs wrap JSON in markdown code blocks.
Common Use Cases¶
- LLM/VLM Output Processing: Parse JSON outputs from Large Language Models and Visual Language Models (e.g., parse GPT JSON responses, extract structured data from LLM outputs, process VLM JSON responses), enabling LLM/VLM output processing workflows
- Structured Data Extraction: Extract structured data from JSON strings for use in workflows (e.g., extract configuration parameters, parse JSON responses, extract structured fields), enabling structured data extraction workflows
- Configuration Parsing: Parse JSON configuration strings into workflow parameters (e.g., parse model configuration, extract workflow parameters, parse JSON configs), enabling configuration parsing workflows
- JSON Response Processing: Process JSON responses from APIs or models (e.g., parse API JSON responses, extract fields from JSON, process JSON data), enabling JSON response processing workflows
- Dynamic Parameter Extraction: Extract dynamic parameters from JSON strings for use in workflow steps (e.g., extract model IDs from JSON, parse dynamic configs, extract parameters dynamically), enabling dynamic parameter workflows
- Data Format Conversion: Convert JSON strings into structured workflow data (e.g., convert JSON to workflow inputs, parse JSON for workflow use, extract JSON fields), enabling data format conversion workflows
Connecting to Other Blocks¶
This block receives JSON strings and produces parsed field outputs:
- After LLM/VLM blocks to parse JSON outputs into structured data (e.g., parse LLM JSON outputs, extract VLM JSON fields, process model JSON responses), enabling LLM/VLM-to-parser workflows
- After workflow inputs to parse JSON input parameters (e.g., parse JSON config inputs, extract JSON parameters, process JSON workflow inputs), enabling input-parser workflows
- Before model blocks to use parsed fields as model parameters (e.g., use parsed model_id for models, use parsed configs for model setup, provide parsed parameters to models), enabling parser-to-model workflows
- Before logic blocks to use parsed fields in conditions (e.g., use parsed values in Continue If, filter based on parsed fields, make decisions using parsed data), enabling parser-to-logic workflows
- Before data storage blocks to store parsed field values (e.g., store parsed JSON fields, log parsed values, save parsed data), enabling parser-to-storage workflows
- In workflow outputs to provide parsed fields as final output (e.g., JSON parsing outputs, structured data outputs, parsed field outputs), enabling parser-to-output workflows
Requirements¶
This block requires a JSON string input (raw JSON or JSON wrapped in Markdown code blocks). The expected_fields parameter specifies which JSON fields to extract as outputs (field names must be valid JSON keys). The error_status field name is reserved and cannot be used in expected_fields. The block supports both raw JSON strings and JSON wrapped in markdown code blocks (json ...). If multiple markdown blocks are found, only the first is parsed. If parsing fails or expected fields are missing, fields are set to None and error_status is set to True. All expected fields become separate outputs that can be referenced in subsequent workflow steps.
Type identifier¶
Use the following identifier in step "type" field: roboflow_core/json_parser@v1to add the block as
as step in your workflow.
Properties¶
| Name | Type | Description | Refs |
|---|---|---|---|
name |
str |
Enter a unique identifier for this step.. | โ |
raw_json |
str |
JSON string to parse. Can be raw JSON string (e.g., '{"key": "value"}') or JSON wrapped in Markdown code blocks (e.g., json {"key": "value"}). Markdown-wrapped JSON is common in LLM/VLM responses. If multiple markdown JSON blocks are present, only the first block is parsed. The string is parsed using Python's JSON parser, and specified fields are extracted as outputs.. |
โ |
expected_fields |
List[str] |
List of JSON field names to extract from the parsed JSON. Each field becomes a separate output that can be referenced in subsequent workflow steps (e.g., $steps.block_name.field_name). Fields that exist in the JSON are extracted with their values; missing fields are set to None. The 'error_status' field name is reserved (always included as output) and cannot be used in this list. Field names must match JSON keys exactly.. | โ |
The Refs column marks possibility to parametrise the property with dynamic values available
in workflow runtime. See Bindings for more info.
Available Connections¶
Compatible Blocks
Check what blocks you can connect to JSON Parser in version v1.
- inputs:
Cosmos 3,Google Gemini,Florence-2 Model,Google Gemini,MoonshotAI Kimi,OpenRouter,Qwen 3.5 API,MoonshotAI Kimi,Anthropic Claude,OpenAI,Anthropic Claude,Google Gemini,OpenAI,Anthropic Claude,Llama 3.2 Vision,Llama 3.2 Vision,Qwen 3.6 API,Florence-2 Model,Google Gemini,Google Gemma API,OpenAI,Google Gemma,OpenAI-Compatible LLM,Qwen-VL,GLM-OCR - outputs:
PLC Writer,Track Class Lock,Image Blur,Byte Tracker,Mask Edge Snap,VLM As Detector,Polygon Visualization,Roboflow Visual Search Classifier,Image Slicer,Qwen3.5-VL,Semantic Segmentation Model,Motion Detection,Keypoint Detection Model,Clip Comparison,Buffer,Label Visualization,MoonshotAI Kimi,Instance Segmentation Model,S3 Sink,Perception Encoder Embedding Model,Velocity,BoT-SORT Tracker,Detection Event Log,Single-Label Classification Model,OPC UA Writer Sink,Background Subtraction,CSV Formatter,Corner Visualization,Detection Offset,JSON Parser,Property Definition,Google Gemini,Seg Preview,Roboflow Custom Metadata,LMM For Classification,PP-OCR,SIFT Comparison,Object Detection Model,Color Visualization,Inner Workflow,Local File Sink,Llama 3.2 Vision,SAM3 Video Tracker,Dynamic Zone,Google Gemma API,Detections Filter,First Non Empty Or Default,Microsoft SQL Server Sink,Icon Visualization,PLC ModbusTCP,Detections Transformation,Rich Label Visualization,Qwen2.5-VL,Twilio SMS/MMS Notification,Identify Changes,OpenAI,Clip Comparison,OpenAI,Instance Segmentation Model,Expression,Stability AI Outpainting,Multi-Label Classification Model,Bounding Box Visualization,Absolute Static Crop,Reference Path Visualization,Google Gemini,Detections Stitch,Event Writer,CogVLM,Time in Zone,Email Notification,Current Time,Mask Area Measurement,Perspective Correction,Cosine Similarity,Detections List Roll-Up,Semantic Segmentation Model,Overlap Filter,Multi-Label Classification Model,Cache Get,OpenRouter,Detections Consensus,OCR Model,Per-Class Confidence Filter,Time in Zone,Relative Static Crop,SAM 3,ByteTrack Tracker,GLM-OCR,Florence-2 Model,Background Color Visualization,Qwen3.5,Roboflow Dataset Upload,Qwen 3.5 API,MoonshotAI Kimi,Stability AI Inpainting,Contrast Equalization,Image Threshold,Camera Focus,Line Counter,Instance Segmentation Model,Circle Visualization,QR Code Generator,Detections Merge,Detections Classes Replacement,Single-Label Classification Model,Heatmap Visualization,Cosmos 3,Auto Rotate on Edges,MQTT Writer,SAM 3,Line Counter,Image Stack,PTZ Tracking (ONVIF),Grid Visualization,Florence-2 Model,Byte Tracker,Pixelate Visualization,Path Deviation,Crop Visualization,Object Detection Model,Detections Stabilizer,Image Convert Grayscale,CLIP Embedding Model,Webhook Sink,VLM As Classifier,SAM 3 Interactive,YOLO-World Model,SIFT,OC-SORT Tracker,Slack Notification,PLC Reader,Stitch OCR Detections,Label Visualization,Email Notification,Keypoint Detection Model,Overlap Analysis,Pixel Color Count,Ellipse Visualization,Path Deviation,Stitch Images,Triangle Visualization,Qwen-VL,Distance Measurement,Bounding Rectangle,Camera Calibration,Polygon Zone Visualization,Delta Filter,Camera Focus,Trace Visualization,Llama 3.2 Vision,Morphological Transformation,Dominant Color,Continue If,SAM2 Video Tracker,Google Vision OCR,Google Gemma,Polygon Visualization,Keypoint Visualization,Image Slicer,Object Detection Model,Keypoint Detection Model,OpenAI,Qwen 3.6 API,Instance Segmentation Model,Single-Label Classification Model,Mask Visualization,Moondream2,Nearest Neighbor Detection Match,Byte Tracker,OpenAI-Compatible LLM,Roboflow Visual Search,VLM As Detector,Blur Visualization,Frame Delay,Roboflow Dataset Upload,OpenAI,Anthropic Claude,Switch Case,Cache Set,Stitch OCR Detections,VLM As Classifier,Barcode Detection,Contrast Enhancement,Template Matching,QR Code Detection,Halo Visualization,Dimension Collapse,Dynamic Crop,PLC EthernetIP,GeoTag Detection,Halo Visualization,Line Counter Visualization,Time in Zone,Roboflow Asset Library Attributes,Multi-Label Classification Model,Size Measurement,LMM,Detections Combine,SIFT Comparison,Depth Estimation,Dot Visualization,EasyOCR,Rate Limiter,Google Gemini,Data Aggregator,Image Contours,Segment Anything 2 Model,Morphological Transformation,SAM 3,Stability AI Image Generation,Google Gemini,Roboflow Vision Events,Model Monitoring Inference Aggregator,Twilio SMS Notification,Anthropic Claude,SORT Tracker,Image Preprocessing,Qwen3-VL,Gaze Detection,Anthropic Claude,Text Display,Model Comparison Visualization,Identify Outliers,Classification Label Visualization,SmolVLM2
Input and Output Bindings¶
The available connections depend on its binding kinds. Check what binding kinds
JSON Parser in version v1 has.
Bindings
-
input
raw_json(language_model_output): JSON string to parse. Can be raw JSON string (e.g., '{"key": "value"}') or JSON wrapped in Markdown code blocks (e.g.,json {"key": "value"}). Markdown-wrapped JSON is common in LLM/VLM responses. If multiple markdown JSON blocks are present, only the first block is parsed. The string is parsed using Python's JSON parser, and specified fields are extracted as outputs..
-
output
Example JSON definition of step JSON Parser in version v1
{
"name": "<your_step_name_here>",
"type": "roboflow_core/json_parser@v1",
"raw_json": "$steps.lmm.output",
"expected_fields": [
"field_a",
"field_b"
]
}