Skip to main content

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?

  1. Add key-value pairs - Define the structure you want
  2. Reference workflow data - Use {{step_X.output}} in keys or values
  3. Block processes - Replaces placeholders with actual data
  4. 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:
Key: keyword
Value: {{step_1.output.Keyword}}
Results in:
{
  "keyword": "crm software"
}

Error Handling

Define what happens if the block fails to create JSON. Options:
  1. Terminate Workflow: Stop execution immediately
  2. Continue Execution: Proceed to next step with empty output
Select based on whether subsequent steps require the JSON data.

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
Input from step 1:
{
  "Keyword": "crm software",
  "Search_Volume": "74000",
  "Keyword_Difficulty_Index": "76"
}
Output:
{
  "keyword": "crm software",
  "search_volume": "74000",
  "difficulty": "76",
  "timestamp": "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}}
Input from step 1:
{
  "Keyword": "email marketing",
  "Search_Volume": "33100"
}
Input from step 2:
{
  "Domain": "mailchimp.com",
  "Organic_Traffic": "15000000",
  "Organic_Keywords": "456789"
}
Output:
{
  "target_keyword": "email marketing",
  "keyword_volume": "33100",
  "competitor_domain": "mailchimp.com",
  "competitor_traffic": "15000000",
  "competitor_keywords": "456789"
}

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
Output:
{
  "event": "keyword_analyzed",
  "keyword": "crm software",
  "metrics": {
    "Keyword": "crm software",
    "Search_Volume": "74000",
    "Keyword_Difficulty_Index": "76"
  },
  "source": "slate_workflow"
}

Best Practices

Naming Keys

  • Use consistent naming: snake_case or camelCase
  • Be descriptive: target_keyword not just keyword
  • 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_X references
  • 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:
Key: source
Value: slate_workflow

Key: version
Value: 1.0

Key: generated_at
Value: 2024-01-15
Combine multiple fields:
Key: title
Value: {{step_1.output.Keyword}} - {{step_1.output.Search_Volume}} searches
Apply transformations:
Key: keyword_slug
Value: {{step_1.output.Keyword | downcase | replace: " ", "-"}}

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
Use Code Block when:
  • 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: