Output Formats

Control how curl-runner displays and saves request results.

Overview

curl-runner provides flexible output options to suit different use cases, from human-readable terminal output to machine-parseable JSON for CI/CD pipelines.

JSON

Structured Data

Machine-readable format for automation

Pretty

Human Readable

Formatted output for terminal viewing

Raw

Unprocessed

Raw response body without formatting

Output Configuration

Configure output settings in the global section of your YAML file.

output-config.yaml
# Different output format configurations
global:
  output:
    format: pretty      # Output format (json, pretty, raw)
    prettyLevel: standard  # Pretty format detail level (minimal, standard, detailed)
    verbose: true       # Show detailed information
    showHeaders: true   # Include response headers
    showBody: true      # Include response body (default: true)
    showMetrics: true   # Include performance metrics

requests:
  - name: API Test
    url: https://api.example.com/data
    method: GET

Configuration Options

OptionTypeDefaultDescription
formatstringpretty"json", "pretty", or "raw"
verbosebooleanfalseShow detailed output
showHeadersbooleanfalseInclude response headers
showBodybooleantrueInclude response body
showMetricsbooleanfalseInclude performance metrics
prettyLevelstringminimal"minimal", "standard", or "detailed" (for pretty format)
saveToFilestring-File path to save results

Format Types

JSON Format

Structured JSON output ideal for parsing and automation.

Configuration

json-config.yaml
# JSON format configuration
global:
  output:
    format: json
    showHeaders: true
    showBody: true
    showMetrics: true

request:
  name: Get User Profile
  url: https://api.example.com/users/123
  method: GET

Output Example

output.json
{
  "summary": {
    "total": 3,
    "successful": 2,
    "failed": 1,
    "duration": 1234,
    "startTime": "2024-01-15T10:30:00Z",
    "endTime": "2024-01-15T10:30:01Z"
  },
  "results": [
    {
      "request": {
        "name": "Get Users",
        "url": "https://api.example.com/users",
        "method": "GET"
      },
      "success": true,
      "status": 200,
      "headers": {
        "content-type": "application/json",
        "x-api-version": "v1"
      },
      "body": {
        "users": [
          { "id": 1, "name": "John Doe" }
        ]
      },
      "metrics": {
        "duration": 125,
        "size": 256
      }
    },
    {
      "request": {
        "name": "Create User",
        "url": "https://api.example.com/users",
        "method": "POST"
      },
      "success": false,
      "status": 400,
      "error": "Validation failed",
      "metrics": {
        "duration": 89,
        "size": 128
      }
    }
  ]
}

Pretty Format

Human-readable format with colors and tree-structured output for terminal viewing. Three detail levels available: minimal, standard, and detailed.

Minimal Format

Compact output showing only essential information

Configuration

pretty-minimal.yaml
# Pretty format - Minimal level
global:
  output:
    format: pretty
    prettyLevel: minimal  # Compact output

request:
  name: Get User Profile
  url: https://api.example.com/users/123
  method: GET

Output Example

terminal
ℹ Found 1 YAML file(s)
ℹ Processing: api-test.yaml

✓ Get User Profile [api-test]
   ├─ GET: https://api.example.com/users/123
   ├─ ✓ Status: 200
   └─ Duration: 125ms | 256.00 B

Summary: 1 request completed successfully

Standard Format

Balanced detail with response body but without headers/metrics (unless specified)

Configuration

pretty-standard.yaml
# Pretty format - Standard level  
global:
  output:
    format: pretty
    prettyLevel: standard  # Balanced detail
    showBody: true

request:
  name: Get User Profile
  url: https://api.example.com/users/123
  method: GET

Output Example

terminal
ℹ Found 1 YAML file(s)
ℹ Processing: api-test.yaml

Executing 1 request(s) in sequential mode

✓ Get User Profile
   ├─ URL: https://api.example.com/users/123
   ├─ Method: GET
   ├─ Status: 200
   ├─ Duration: 125ms
   └─ Response Body:
      {
        "id": 123,
        "name": "John Doe",
        "email": "john@example.com",
        "active": true
      }


Summary: 1 request completed successfully (125ms)

Detailed Format

Full information including headers, body, and performance metrics

Configuration

pretty-detailed.yaml
# Pretty format - Detailed level
global:
  output:
    format: pretty
    prettyLevel: detailed  # Full information
    # Headers and metrics are shown automatically

request:
  name: Get User Profile
  url: https://api.example.com/users/123
  method: GET

Output Example

terminal
ℹ Found 1 YAML file(s)
ℹ Processing: api-test.yaml

Executing 1 request(s) in sequential mode

  Command:
    curl -X GET -w "
__CURL_METRICS_START__%{json}__CURL_METRICS_END__" -L -s -S "https://api.example.com/users/123"
✓ Get User Profile
   ├─ URL: https://api.example.com/users/123
   ├─ Method: GET
   ├─ Status: 200
   ├─ Duration: 125ms
   ├─ Response Body:
   │  {
   │    "id": 123,
   │    "name": "John Doe",
   │    "email": "john@example.com",
   │    "active": true
   │  }
   └─ Metrics:
      ├─ Request Duration: 125ms
      ├─ Response Size: 256.00 B
      ├─ DNS Lookup: 5ms
      ├─ TCP Connection: 10ms
      ├─ TLS Handshake: 15ms
      └─ Time to First Byte: 95ms


Summary: 1 request completed successfully (125ms)

Raw Format

Unprocessed response body, useful for binary data or custom formats.

Configuration

raw-config.yaml
# Raw format configuration
global:
  output:
    format: raw
    showBody: true

request:
  name: Get User Profile
  url: https://api.example.com/users/123
  method: GET

Output Example

response.json
{
  "id": 123,
  "name": "John Doe", 
  "email": "john@example.com",
  "active": true
}

Saving Results

Save test results to files for later analysis or reporting.

save-to-file.yaml
# Save results to file
global:
  output:
    format: json
    saveToFile: test-results.json  # Save all results to file
    verbose: false                  # Quiet terminal output
  variables:
    API_URL: https://api.example.com

requests:
  - name: Test Suite
    url: ${API_URL}/test
    method: GET

Tip: Use saveToFile with JSON format to create test reports that can be processed by other tools or stored for historical analysis.

CLI Options

Control output format from the command line.

terminal
# Command line output options
# JSON format (machine-readable)
curl-runner tests.yaml --output-format json

# Pretty format with different detail levels
curl-runner tests.yaml --output-format pretty --pretty-level minimal
curl-runner tests.yaml --output-format pretty --pretty-level standard
curl-runner tests.yaml --output-format pretty --pretty-level detailed

# Raw format (response body only)
curl-runner tests.yaml --output-format raw

# Save to file
curl-runner tests.yaml --output results.json

# Verbose mode
curl-runner tests.yaml --verbose

# Show specific components
curl-runner tests.yaml --show-headers --show-metrics

# Quiet mode (errors only)
curl-runner tests.yaml --quiet

Output Flags

FlagDescription
--output-formatSet output format (json/pretty/raw)
--pretty-levelSet pretty format detail level (minimal/standard/detailed)
--output, -oSave results to file
--verbose, -vEnable verbose output
--quiet, -qSuppress non-error output
--show-headersInclude response headers
--show-bodyInclude response body
--show-metricsInclude performance metrics

Use Cases

Continuous Integration

Use JSON format with file output for test reporting in CI pipelines. Perfect for automated testing and build systems.

curl-runner tests.yaml --output-format json -o results.json --quiet

Local Testing

Use pretty format with verbose output for debugging. Ideal for development and troubleshooting.

curl-runner tests.yaml --output-format pretty -v --show-metrics

Health Checks & Monitoring

Use raw format for simple status checks and monitoring scripts. Extract specific data without extra formatting.

curl-runner health.yaml --output-format raw --quiet

Best Practices

Choose the Right Format

Use JSON for automation, pretty for debugging, and raw for specific data formats.

Save Important Results

Always save test results to files in CI/CD environments for audit trails.

Use Quiet Mode in Scripts

Reduce noise in automated scripts by using quiet mode with file output.

Enable Metrics for Performance Testing

Include metrics in output when analyzing API performance.