> This page is for Fern CLI.

> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. For task-scoped instructions for coding agents working in a Fern project, see https://buildwithfern.com/learn/home/fern-instructions.md.

# Overview

> Learn how to use the Fern CLI to manage API projects, validate definitions, preview changes, and publish docs and SDKs.

The Fern CLI lets you initialize projects, validate API definitions, preview changes locally, and publish documentation and SDKs. This page covers installation and common commands to get you started.

#### Get started with Fern CLI

Install and use the Fern CLI. Follow the [Fern CLI guide](https://buildwithfern.com/learn/cli-api-reference/cli-reference/overview.md) step by step.

## Installation

Install the Fern CLI with npm or Homebrew.

#### npm

Requires [Node.js](https://nodejs.org/) 22 or higher, which ships with npm 10 or higher. If you're on an older version, [upgrade Node.js](https://nodejs.org/).

```bash
npm install -g fern-api
fern -v
```

#### Homebrew

Available on macOS and Linux via [Homebrew](https://brew.sh/). Homebrew installs Node.js automatically as a dependency, so no separate setup is needed.

```bash
brew install fern-api
fern -v
```

### Alternative: install as a project dependency

Most users install Fern globally with the commands above. Install it locally instead to pin its version per project or to work in an environment with limited internet connectivity. Local installs use npm. Homebrew supports only system-wide installs.

#### Add Fern to your project

```bash
npm install fern-api
```

#### Set the version to your local install

In `fern.config.json`, set the version to `*`:

**`fern.config.json`**

```json fern.config.json {3}
{
  "organization": "your-org",
  "version": "*"
}
```

The [`fern.config.json` reference](/learn/sdks/overview/project-structure#fernconfigjson) covers the remaining fields.

#### Run commands through npm

```bash
npm fern check
npm fern generate
```

## CLI workflows by product

The Fern CLI manages both documentation and SDK workflows. Below is a brief overview of the common commands for each. All commands support [global options](/learn/cli-api-reference/cli-reference/options) like `--log-level` for debugging.

The [general](/learn/cli-api-reference/cli-reference/general-commands), [docs](/learn/cli-api-reference/cli-reference/docs-commands), and [SDK](/learn/cli-api-reference/cli-reference/sdk-commands) command references document every command and flag in full.

#### Docs workflow

When working with Fern Docs, you'll use these CLI commands. For complete instructions, see the [Docs quickstart](/learn/docs/getting-started/quickstart).

| Command                | Description                              |
| ---------------------- | ---------------------------------------- |
| `fern init --docs`     | Create a new docs project                |
| `fern docs dev`        | Preview docs locally at `localhost:3000` |
| `fern generate --docs` | Publish documentation to production      |

#### SDK workflow

When working with Fern SDKs, you'll use these CLI commands. For complete instructions, see the [SDKs quickstart](/learn/sdks/overview/quickstart).

| Command                             | Description                               |
| ----------------------------------- | ----------------------------------------- |
| `fern init`                         | Create a new SDK project                  |
| `fern check`                        | Validate your API definition              |
| `fern generate --preview`           | Preview SDKs locally in `.preview/`       |
| `fern generate`                     | Publish SDKs to production                |
| `fern generate --target <language>` | Generate one target from `sdk-config.yml` |
| `fern generate --group <name>`      | Generate a legacy SDK group               |