Neon CLI
Use the Neon CLI to manage Neon directly from the terminal
The Neon CLI is a command-line interface that lets you manage Neon directly from the terminal. This documentation references all commands and options available in the Neon CLI.
Install
Install with Homebrew
brew install neonctlInstall via npm
npm i -g neonctlRequires Node.js 18.0 or higher.
Install with bun
bun install -g neonctlmacOS binary
Download the binary. No installation required.
curl -sL https://github.com/neondatabase/neonctl/releases/latest/download/neonctl-macos -o neonctlRun the CLI from the download directory:
neonctl <command> [options]For more about installing, upgrading, and connecting, see Neon CLI — Install and connect.
Use the Neon CLI without installing
You can run the Neon CLI without installing it using npx (Node Package eXecute) or the bun equivalent, bunx. For example:
# npx
npx neonctl <command>
# bunx
bunx neonctl <command>Synopsis
neonctl --help
usage: neonctl <command> [options]                               [aliases: neon]
Commands:
  neonctl auth                        Authenticate                      [aliases: login]
  neonctl me                          Show current user
  neonctl orgs                        Manage organizations                [aliases: org]
  neonctl projects                    Manage projects                 [aliases: project]
  neonctl ip-allow                    Manage IP Allow
  neonctl branches                    Manage branches                   [aliases: branch]
  neonctl databases                   Manage databases            [aliases: database, db]
  neonctl roles                       Manage roles                        [aliases: role]
  neonctl operations                  Manage operations               [aliases: operation]
  neonctl connection-string [branch]  Get connection string                  [aliases: cs]
  neonctl set-context                 Set the current context
  neonctl create-app                  Initialize a new Neon project   [aliases: bootstrap]
  neonctl completion                  generate completion script
Global options:
  -o, --output      Set output format
                  [string] [choices: "json", "yaml", "table"] [default: "table"]
  --config-dir      Path to config directory [string] [default: ""]
  --api-key         API key  [string] [default: ""]
  --analytics       Manage analytics. Example: --no-analytics, --analytics false
                                                       [boolean] [default: true]
  -v, --version     Show version number                                [boolean]
  -h, --help        Show help                                          [boolean]
Options:
--context-file      Context file [string] [default: (current-context-file)]Commands
| Command | Subcommands | Description | 
|---|---|---|
| auth | Authenticate | |
| me | Show current user | |
| orgs | list | Manage organizations | 
| projects | list,create,update,delete,get | Manage projects | 
| ip-allow | list,add,remove,reset | Manage IP Allow | 
| branches | list,create,reset,restore,rename,schema-diff,set-default,add-compute,delete,get | Manage branches | 
| databases | list,create,delete | Manage databases | 
| roles | list,create,delete | Manage roles | 
| operations | list | Manage operations | 
| connection-string | Get connection string | |
| set-context | Set context for session | |
| create-app | Initialize a new Neon project | |
| completion | Generate a completion script | 
Global options
Global options are supported with any Neon CLI command.
| Option | Description | Type | Default | 
|---|---|---|---|
| -o, --output | Set the Neon CLI output format ( json,yaml, ortable) | string | table | 
| --config-dir | Path to the Neon CLI configuration directory | string | /home/<user>/.config/neonctl | 
| --api-key | Neon API key | string | NEON_API_KEYenvironment variable | 
| --color | Colorize the output. Example: --no-color,--color false | boolean | true | 
| --analytics | Manage analytics | boolean | true | 
| -v, --version | Show the Neon CLI version number | boolean | - | 
| -h, --help | Show the Neon CLI help | boolean | - | 
- 
Sets the output format. Supported options are json,yaml, andtable. The default istable. Table output may be limited. Thejsonandyamloutput formats show all data.neon me --output json
- 
Specifies the path to the neonctlconfiguration directory. To view the default configuration directory containing youcredentials.jsonfile, runneon --help. The credentials file is created when you authenticate using theneon authcommand. This option is only necessary if you move yourneonctlconfiguration file to a location other than the default.neonctl projects list --config-dir /home/<user>/.config/neonctl
- 
Specifies your Neon API key. You can authenticate using a Neon API key when running a Neon CLI command instead of using neonctl auth. For information about obtaining an Neon API key, see Create an API key.neon <command> --api-key <neon_api_key>To avoid including the --api-keyoption with each CLI command, you can export your API key to theNEON_API_KEYenvironment variable.export NEON_API_KEY=<neon_api_key>infoThe authentication flow for the Neon CLI follows this order: - If the --api-keyoption is provided, it is used for authentication.
- If the --api-keyoption is not provided, theNEON_API_KEYenvironment variable setting is used.
- If there is no --api-keyoption orNEON_API_KEYenvironment variable setting, the CLI looks for thecredentials.jsonfile created by theneon authcommand.
- If the credentials file is not found, the Neon CLI initiates the neon authweb authentication process.
 
- If the 
- 
Colorize the output. This option is enabled by default, but you can disable it by specifying --no-coloror--color false, which is useful when using Neon CLI commands in your automation pipelines.
- 
Analytics are enabled by default to gather information about the CLI commands and options that are used by our customers. This data collection assists in offering support, and allows for a better understanding of typical usage patterns so that we can improve user experience. Neon does not collect user-defined data, such as project IDs or command payloads. To opt-out of analytics data collection, specify --no-analyticsor--analytics false.
- 
Shows the Neon CLI version number. $ neon --version 1.15.0
- 
Shows the neonctlcommand-line help. You can view help forneonctl, aneonctlcommand, or aneonctlsubcommand, as shown in the following examples:neon --help neon branches --help neon branches create --help
Options
| Option | Description | Type | Default | 
|---|---|---|---|
| --context-file | The context file for CLI sessions | string | current-context-file | 
- 
Sets a background context for your CLI sessions, letting you perform organization, project, or branch-specific actions without having to specify the relevant id in every command. For example, this command lists all branches using the branches listcommand. No need to specify the project since the context file provides it.neon branches list --context-file path/to/context_file_nameTo define a context file, see Neon CLI commands — set-context. 
GitHub repository
The GitHub repository for the Neon CLI is found here.