OpenAPI Viewer & curl Generator — Browse Swagger / OAS 3 Specs and Copy curl Commands Online
Free online OpenAPI viewer and Swagger viewer with a built-in curl generator. Paste OpenAPI 3.x or Swagger 2.0 JSON/YAML, browse operations by tag, pick a server, and copy a ready-to-run curl command per endpoint. Learn how base URLs, path parameters, query strings, request bodies, and security placeholders are built into each curl command — all client-side, no upload.
Browse any OpenAPI / Swagger spec and get copy-paste curl commands — in seconds
Spoold's OpenAPI viewer parses OpenAPI 3.x and Swagger 2.0 specs (JSON or YAML) entirely in your browser. Filter operations by path, method, tag, or operationId, choose a server base URL, and copy a curl command per endpoint. Nothing is uploaded — your spec never leaves the browser tab.
Why an online OpenAPI viewer with curl?
Teams building REST APIs document their contracts in OpenAPI 3 (formerly Swagger). Reading raw JSON or YAML is tedious, and full-blown tools like Swagger UI require a running server. Spoold's viewer is a lightweight alternative: paste your spec, browse tagged operations, and grab a curl command you can run immediately in a terminal.
🔥 On-call debugging
Paste the spec from your service repo, find the right endpoint, copy the curl, and hit the API.
👀 Code review
Review OpenAPI diffs by pasting each version side by side in two tabs.
🔌 Vendor API exploration
Drop a third-party spec to understand available endpoints without installing anything.
📋 Documentation preview
Confirm that paths, parameters, and security are well-defined before publishing.
Supported formats
The viewer auto-detects the input format. If the text starts with { it is parsed as JSON; otherwise as YAML. Internal $ref pointers (e.g. #/components/schemas/Pet) are resolved automatically.
How to use the viewer — step by step
Open the tool
Go to OpenAPI viewer or click the Sample button to load the built-in Petstore demo.
Paste or upload your spec
Paste JSON/YAML into the editor, or drag-and-drop a file. The spec is parsed client-side.
Choose a server
If the spec defines multiple servers (OpenAPI 3) or schemes×host (Swagger 2), use the dropdown to pick the base URL. Server variables are substituted with their defaults.
Browse operations
Operations are grouped by tag. Use the search bar to filter by path, method, operationId, or summary. Click a row to expand it.
Copy curl
Click Copy curl on any row. The command is built from your spec and the selected server — ready to paste into a terminal.
Inspect details
Expand a row to see the full curl command, parameter table, sample request body, and the primary sample response.
How the curl generator works
Every curl command is derived deterministically from the spec. Below is exactly what happens at each stage.
$Command shape
Every command starts with curl -sS -X METHOD. The flags -sS suppress the progress meter but still show errors. All variable parts — URL, headers, body — are wrapped in POSIX-safe single quotes. Literal single quotes inside values are escaped as '\'' (end quote, backslash-escaped quote, resume quote), making the output safe for any POSIX shell.
🌐Base URL and path
The base URL comes from the server dropdown you select in the UI.
OpenAPI 3
Each entry in the servers array is resolved. Server variable placeholders like {version} are replaced with the variable's default value.
Swagger 2
The URL is composed from schemes × host × basePath.
When no servers are declared, the fallback is https://api.example.com.
/Path parameters
Parameters are merged from path-item level and operation level (operation overrides for the same name). Each {id} placeholder is replaced with:
- The parameter's
example(orschema.example), if defined. - A synthetic value from the schema type —
"string",0,false. - The fallback literal
examplewhen nothing else is available.
All values are encodeURIComponent-encoded to handle special characters.
?Query parameters
Only required query params (or optional ones with an example) are included. This keeps the curl concise — optional fields without examples are omitted. Names and values are URL-encoded.
HHeader parameters
Included only when the spec provides an example value. Each becomes a -H 'Name: value' flag. Duplicate header names are deduplicated.
{}Request body (JSON)
OpenAPI 3
Looks at requestBody.content and picks the best media type (application/json first, then application/*+json variants). Uses the media type's example if present, or synthesises a JSON object from the schema.
Swagger 2
Uses the first in: "body" parameter's schema to generate the JSON body.
The body is sent via -d, and a Content-Type header is added automatically.
🔒Security placeholders
The generator reads the first security requirement object — operation-level if defined, otherwise global. For each scheme:
-H 'Authorization: Bearer YOUR_TOKEN'-H 'Authorization: Basic BASE64_USER_COLON_PASS'-H 'X-Api-Key: YOUR_API_KEY'-H 'Authorization: Bearer YOUR_ACCESS_TOKEN'These are placeholder values — replace them with real credentials before running. API keys in query params and cookie-based auth are not generated; add those manually.
⚠️ What to edit before running
- Replace
YOUR_TOKEN,YOUR_API_KEY, orBASE64_USER_COLON_PASSwith real credentials. - Check path parameters — spec-less substitutions like
"string"or0need real IDs. - Review the request body — schema-derived bodies use type defaults, which may not be a valid payload.
Example: from spec to curl
Given this OpenAPI 3 fragment:
openapi: "3.0.3"
info:
title: Petstore
version: "1.0.0"
servers:
- url: https://petstore.example.com/v1
paths:
/pets/{petId}:
get:
operationId: getPet
summary: Get a pet by ID
parameters:
- name: petId
in: path
required: true
schema:
type: integer
example: 42
security:
- bearerAuth: []
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearerThe viewer generates:
curl -sS -X GET 'https://petstore.example.com/v1/pets/42' \ -H 'Authorization: Bearer YOUR_TOKEN'
petId was replaced with its example value 42, and the Bearer auth placeholder was added from the bearerAuth security scheme.Schema-to-example generation
When a spec does not include explicit example values, the curl generator synthesises a JSON body from the schema:
| Schema type | Generated value |
|---|---|
| string | "string" (or default if set) |
| integer / number | 0 |
| boolean | false |
| array | One-element array from items schema |
| object | Recurse into properties |
| allOf | Merge all branches into one object |
| oneOf / anyOf | First branch that produces a value |
| $ref | Resolved, then processed recursively |
Tips for better curl output
📝 Add examples to your spec
The generator prefers explicit example values. Adding them produces more realistic curl commands.
🔐 Define security schemes
Without securitySchemes, the curl will have no auth headers. Define them even if you override per-operation.
🌍 Use multiple servers
Define staging and production URLs in the servers array to switch between them in the dropdown.
🏷️ Tag your operations
Operations grouped by tag are easier to browse. The viewer collapses operations into tag sections.
How this compares to Swagger UI
Swagger UI is the official OpenAPI renderer — feature-rich but requires hosting. Spoold's viewer takes a different approach:
| Swagger UI | Spoold Viewer | |
|---|---|---|
| Setup | Host static files or Node | Paste and go |
| Primary action | Try it out (execute) | Copy curl |
| Privacy | Depends on host | Never leaves browser |
| Auth flows | Full OAuth UI | Placeholder headers |
| Weight | ~5 MB bundle | Lightweight, in-page |
Think of it as a read-only Swagger UI alternative optimised for quick curl extraction.
Frequently asked questions
Does this tool send my spec to a server?
Can I use it with private or internal APIs?
What happens if my spec has $ref to external files?
#/... pointers are resolved. External file references are not fetched. Bundle your spec first with swagger-cli bundle or redocly bundle.Why are some query parameters missing from the curl?
example are omitted to keep the command clean. Mark them required: true or add examples to include them.Can I edit the curl after copying?
Does it support GraphQL or gRPC specs?
Related tools
OpenAPI viewer & curl
The tool described in this guide.
curl → Code
Convert curl to fetch, Axios, Python, and more.
curl Compare
Diff two curl commands side by side.
JSON Formatter
Pretty-print the JSON spec before pasting.
JSON ↔ YAML
Convert your spec between JSON and YAML.
Try it now — paste your OpenAPI spec
Open the viewer, paste any OpenAPI 3 or Swagger 2 spec, and copy curl commands per endpoint. Free, client-side, no sign-up.
Related Articles
JSON Schema Validator Online: Validate JSON Against a Schema
Learn what JSON Schema is, which drafts matter (4–2020-12), how SchemaStore helps, and how to use a free browser validator for APIs, configs, and package.json.
TOML Formatter & Validator Online: Pretty-Print and Check Cargo.toml, pyproject.toml
Learn what TOML is, how online formatting and validation help Rust and Python configs, why comments disappear on format, and how to use Spoold’s free browser tool.
QR Code Samples: Copyable Links & Text to Generate QR Codes
Copy-paste sample QR payloads: URLs, plain text, Wi‑Fi (WIFI:), and vCard (BEGIN:VCARD). Free online QR generator; sample PNGs for Spoold, the QR tool, and hello text. WiFi QR, vCard QR, developer samples.