Back to Blog
12 min read
Guide

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

OpenAPI 3.0OpenAPI 3.1Swagger 2.0JSONYAML

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

1

Open the tool

Go to OpenAPI viewer or click the Sample button to load the built-in Petstore demo.

2

Paste or upload your spec

Paste JSON/YAML into the editor, or drag-and-drop a file. The spec is parsed client-side.

3

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.

4

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.

5

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.

6

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:

  1. The parameter's example (or schema.example), if defined.
  2. A synthetic value from the schema type — "string", 0, false.
  3. The fallback literal example when 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:

Bearer-H 'Authorization: Bearer YOUR_TOKEN'
Basic auth-H 'Authorization: Basic BASE64_USER_COLON_PASS'
API key (header)-H 'X-Api-Key: YOUR_API_KEY'
OAuth2-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, or BASE64_USER_COLON_PASS with real credentials.
  • Check path parameters — spec-less substitutions like "string" or 0 need 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:

petstore.yaml
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: bearer

The viewer generates:

Generated curl
curl -sS -X GET 'https://petstore.example.com/v1/pets/42' \
  -H 'Authorization: Bearer YOUR_TOKEN'
What happened: The path parameter 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 typeGenerated value
string"string" (or default if set)
integer / number0
booleanfalse
arrayOne-element array from items schema
objectRecurse into properties
allOfMerge all branches into one object
oneOf / anyOfFirst branch that produces a value
$refResolved, 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 UISpoold Viewer
SetupHost static files or NodePaste and go
Primary actionTry it out (execute)Copy curl
PrivacyDepends on hostNever leaves browser
Auth flowsFull OAuth UIPlaceholder headers
Weight~5 MB bundleLightweight, 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?
No. Parsing, rendering, and curl generation all happen in your browser. The spec is never uploaded.
Can I use it with private or internal APIs?
Yes. Everything runs client-side, so you can paste specs for internal services without worrying about data leakage.
What happens if my spec has $ref to external files?
Only internal #/... 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?
Optional query parameters without an 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?
Absolutely. It's just text on your clipboard. You can also paste it into Spoold's curl → Code converter to get JavaScript fetch, Python requests, or other languages.
Does it support GraphQL or gRPC specs?
No — it's specifically for OpenAPI / Swagger REST specs. For GraphQL, see our GraphQL formatter.

Related tools

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.

Try It Now

Put this guide into practice with our free tools. No sign-up required.

Open the Viewer
OpenAPI Viewer & curl Generator — Browse Swagger / OAS 3 Specs and Copy curl Commands Online | Spoold Blog | Spoold