---
title: "nuxt curl"
description: "The curl command sends an HTTP request to your running Nuxt dev server."
canonical_url: "https://nuxt.com/docs/4.x/api/commands/curl"
---
# nuxt curl

> The curl command sends an HTTP request to your running Nuxt dev server.

```bash [Terminal]
npx nuxt curl <URL> [ROOTDIR] [--cwd=<directory>] [-X, --method=<method>] [-H, --header=<header>...] [-d, --data=<data>] [-i, --include] [-I, --head] [-v, --verbose] [--pretty]
```

The `curl` command sends an HTTP request to the `nuxt dev` server running for your project and prints the response. A path is resolved against that server, so you do not need to know which port it ended up on.

![nuxt curl](https://raw.githubusercontent.com/nuxt/cli/main/capture/output/nuxt-curl.svg)

## Arguments

<table>
<thead>
  <tr>
    <th>
      Argument
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        URL=<url|path>
      </code>
    </td>
    
    <td>
      Absolute URL, or a path resolved against the running dev server
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ROOTDIR
      </code>
    </td>
    
    <td>
      The root directory of your Nuxt project (default: .)
    </td>
  </tr>
</tbody>
</table>

## Options

<table>
<thead>
  <tr>
    <th>
      Option
    </th>
    
    <th>
      Default
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        --cwd=<directory>
      </code>
    </td>
    
    <td>
      
    </td>
    
    <td>
      Specify the root directory of your Nuxt project
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        -X, --method=<method>
      </code>
    </td>
    
    <td>
      
    </td>
    
    <td>
      HTTP method (default: GET, or POST when a body is provided)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        -H, --header=<header>...
      </code>
    </td>
    
    <td>
      
    </td>
    
    <td>
      Request header in <code>
        Name: Value
      </code>
      
       form. Can be repeated.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        -d, --data=<data>
      </code>
    </td>
    
    <td>
      
    </td>
    
    <td>
      Request body. Use <code>
        @-
      </code>
      
       to read stdin and <code>
        @<file>
      </code>
      
       to read a file.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        -i, --include
      </code>
    </td>
    
    <td>
      
    </td>
    
    <td>
      Include the response status line and headers in the output
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        -I, --head
      </code>
    </td>
    
    <td>
      
    </td>
    
    <td>
      Send a <code>
        HEAD
      </code>
      
       request and show only the response headers
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        -v, --verbose
      </code>
    </td>
    
    <td>
      
    </td>
    
    <td>
      Print request and response headers to stderr
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --pretty
      </code>
    </td>
    
    <td>
      
    </td>
    
    <td>
      Reindent and syntax-highlight output (default: on for a terminal, off when piped). Use <code>
        --pretty
      </code>
      
      /<code>
        --no-pretty
      </code>
      
       to force reindenting.
    </td>
  </tr>
</tbody>
</table>

The dev server is found through the `nuxt.lock` file it writes into your [build directory](https://nuxt.com/docs/4.x/directory-structure/nuxt), so the command only works while `nuxt dev` is running for that project. Pass an absolute URL to talk to any other server.

**Examples:**

```bash [Terminal]
# Request a path on the running dev server
npx nuxt curl /api/hello

# Include the status line and response headers
npx nuxt curl /api/hello -i

# Send JSON
npx nuxt curl /api/todos -X POST -H "Content-Type: application/json" -d '{"title":"Buy milk"}'

# Read the body from a file, or from stdin with `@-`
npx nuxt curl /api/todos -d @todo.json
```

JSON, HTML, XML and other textual responses are reindented and syntax-highlighted when the output is a terminal, and passed through byte for byte when it is piped. Use `--no-pretty` to opt out, or `--pretty` to force it on when piping.

::note
The command exits with `22` when the server answers with an HTTP error status, matching `curl --fail`.
::

---

- [Source](https://github.com/nuxt/cli/blob/main/packages/nuxt-cli/src/commands/curl.ts)


## Sitemap

See the full [sitemap](https://nuxt.com/sitemap.md) for all pages.
