Documentation Index
Fetch the complete documentation index at: https://slatehq.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
What is the Convert to JSON Block?
The Convert to JSON block creates structured JSON objects by defining key-value pairs. Use it to format workflow data into a specific JSON structure for APIs, databases, or downstream processing. Common use cases:- Create API request payloads
- Structure data for external services
- Format data for Google Sheets or databases
- Build JSON objects from multiple step outputs
- Create standardized data formats
- Prepare data for webhooks
- Transform unstructured data into structured JSON
How Does the Convert to JSON Block Work?
- Add key-value pairs - Define the structure you want
- Reference workflow data - Use
{{step_X.output}}in keys or values - Block processes - Replaces placeholders with actual data
- Returns JSON object - Structured output ready to use
Configuration
Key-Value Pairs
Add pairs of keys and values to build your JSON structure. Key: The property name in the JSON object Value: The data to assign (can be static text or references to previous steps) Click Add pair to add more key-value pairs.Using Variables
Both keys and values support Liquid templating syntax to reference previous steps. Basic reference:Error Handling
Define what happens if the block fails to create JSON. Options:- Terminate Workflow: Stop execution immediately
- Continue Execution: Proceed to next step with empty output
Use Cases and Examples
Use Case 1: Create API Payload
Scenario: Format keyword data for an API request Configuration:- Key:
keyword| Value:{{step_1.output.Keyword}} - Key:
search_volume| Value:{{step_1.output.Search_Volume}} - Key:
difficulty| Value:{{step_1.output.Keyword_Difficulty_Index}} - Key:
timestamp| Value:2024-01-15
Use Case 2: Combine Multiple Step Outputs
Scenario: Merge data from keyword research and competitor analysis Configuration:- Key:
target_keyword| Value:{{step_1.output.Keyword}} - Key:
keyword_volume| Value:{{step_1.output.Search_Volume}} - Key:
competitor_domain| Value:{{step_2.output.Domain}} - Key:
competitor_traffic| Value:{{step_2.output.Organic_Traffic}} - Key:
competitor_keywords| Value:{{step_2.output.Organic_Keywords}}
Use Case 3: Build Webhook Payload
Scenario: Send structured data to external webhook Configuration:- Key:
event| Value:keyword_analyzed - Key:
keyword| Value:{{step_1.output.Keyword}} - Key:
metrics| Value:{{step_1.output}} - Key:
source| Value:slate_workflow
Best Practices
Naming Keys
- Use consistent naming: snake_case or camelCase
- Be descriptive:
target_keywordnot justkeyword - Follow conventions: Match API or database requirements
- Avoid special characters: Stick to alphanumeric and underscores
Structuring Data
- Group related data: Use clear, logical organization
- Keep it flat when possible: Avoid unnecessary nesting
- Include metadata: Add timestamps, sources, IDs
- Validate required fields: Ensure all necessary data is included
Using References
- Verify step numbers: Double-check
step_Xreferences - Test with sample data: Run workflow to verify output
- Handle missing data: Use filters with defaults
- Document structure: Comment what each field represents
Common Patterns
Add static metadata:Troubleshooting
Output Not Showing Expected Data
Problem: JSON contains{{step_1.output}} instead of actual values.
Solution:
- Verify step number is correct
- Ensure previous step completed successfully
- Check step actually has output data
- Test reference in Text block first
Keys Are Empty or Incorrect
Problem: JSON keys are blank or not as expected. Solution:- Keys should be static text (use plain text for keys)
- If using dynamic keys, ensure Liquid syntax is correct
- Avoid using complex Liquid in keys
Values Not Transforming
Problem: Filters not applying to values. Solution:- Check Liquid filter syntax
- Ensure data type matches filter (string/number/array)
- Test filter in Text block first
- See Liquid Templating for correct syntax
Invalid JSON Structure
Problem: Output is not valid JSON. Solution:- Ensure all keys are unique
- Check for special characters in keys
- Verify all values are properly formatted
- Test with simple static values first
Comparing with Code Block
Use Convert to JSON when:- You need simple key-value mapping
- Structure is straightforward
- No complex logic required
- Quick JSON creation from existing data
- Need complex transformations
- Conditional structure building
- Dynamic key generation
- Nested object creation
- Array processing
What’s Next
Now that you understand the Convert to JSON block:- Transform data with Code Block
- Format text with Text Block
- Send data to APIs with Call API
- Save to Google Sheets
- Learn Liquid Templating for advanced formatting
- Learn about Variable Referencing