← All tools

Data & Analysis

JSON Transform

Parse, query, extract, and reshape JSON.

json_transform

Overview

Most online services return data in a format called JSON. This tool lets the agent grab a specific field out of that reply, reshape it, or convert it to a spreadsheet — the plumbing that chains steps of a workflow together.

How it works

Accepts a JSON payload and applies one of four operations: 'extract' pulls a single value at a dot-notation path (e.g. 'user.email'); 'query' returns all values matching a path; 'flatten' converts a nested object into a flat key-value map; 'to_csv' converts a JSON array of objects into a CSV string.

Example

When a user asks:

Pull the user's email out of this API response.

the agent calls the tool:

json_transform(json="{…}", operation="extract", path="user.email")

and gets back: the single value at that path — e.g. "jane@example.com".

Use it in a workflow

Wire this tool into a SwarmAI crew. Use the YAML DSL for declarative workflows, or the Java builder API when you want full programmatic control.

YAML DSL

# data-glue.yaml
name: data-glue-crew
process: SEQUENTIAL

agents:
  - id: shaper
    role: Data Glue
    goal: Reshape JSON between pipeline steps
    tools:
      - json_transform

tasks:
  - id: data-glue-task
    agent: shaper
    description: Extract the 'user.email' field from the supplied JSON payload.

Java

import ai.intelliswarm.swarmai.agent.Agent;
import ai.intelliswarm.swarmai.task.Task;
import ai.intelliswarm.swarmai.swarm.Swarm;
import ai.intelliswarm.swarmai.swarm.SwarmOutput;
import ai.intelliswarm.swarmai.process.ProcessType;
import ai.intelliswarm.swarmai.tool.common.JSONTransformTool;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;

@Autowired ChatClient chatClient;
@Autowired JSONTransformTool jSONTransformTool;

Agent shaper = Agent.builder()
    .role("Data Glue")
    .goal("Reshape JSON between pipeline steps")
    .chatClient(chatClient)
    .tool(jSONTransformTool)
    .build();

Task shaperTask = Task.builder()
    .description("Extract the 'user.email' field from the supplied JSON payload.")
    .agent(shaper)
    .build();

SwarmOutput result = Swarm.builder()
    .agent(shaper)
    .task(shaperTask)
    .process(ProcessType.SEQUENTIAL)
    .build()
    .kickoff();

What it's good for

Real scenarios where agents put this tool to work.

Extracting fields from API responses with dot-paths
Flattening nested JSON for downstream tools
JSON → CSV conversion in ETL-style crews
Payload reshaping between http_request and report_generator

Source

Implementation lives at swarmai-tools/src/main/java/ai/intelliswarm/swarmai/tool/common/JSONTransformTool.java in the swarm-ai repository.

Open json_transform on GitHub →