All posts
Developer Tools·5 min read·Updated 23 Oct 2026

How to Install Codex CLI on Windows, Mac and Linux (2026)

Quick answer
Install OpenAI's Codex CLI with `npm install -g @openai/codex`, `brew install --cask codex`, or the official script — `curl -fsSL https://chatgpt.com/codex/install.sh | sh` on Mac and Linux, or a PowerShell one-liner on Windows. Then run `codex` and choose Sign in with ChatGPT.

Install OpenAI's Codex CLI on Windows, macOS or Linux with the official script, npm or Homebrew, sign in with ChatGPT or an API key, and fix the common install problems.

Piyush Jangir
Verified author

Founder of StackPicks. Self-taught builder shipping open-source dev tools, marketing, and curator content since 2019. Based in Mumbai, India. Available on GitHub and LinkedIn.

5 min read
How to Install Codex CLI on Windows, Mac and Linux (2026)

**Short version:** Codex CLI is OpenAI's terminal coding agent (openai/codex, Apache-2.0, about 130,000 GitHub stars). There are four official ways to install it; pick the one that matches how you already manage tools. Every command below is from the project's README.

The four official ways to install Codex CLI

Mac and Linux: the install script

curl -fsSL https://chatgpt.com/codex/install.sh | sh

Windows: PowerShell

Codex has a native Windows installer. In PowerShell:

powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"

Any platform: npm

If you already have Node.js:

npm install -g @openai/codex

Mac: Homebrew

brew install --cask codex

Prebuilt binaries for Apple Silicon and Intel Macs and for x86_64 and arm64 Linux are also on the project's GitHub Releases page.

First run and sign-in

First run of Codex CLI: install, launch, sign in, start a task

  1. Open a terminal in the project you want to work on.
  2. Run codex.
  3. Choose Sign in with ChatGPT — recommended for Plus, Pro, Business, Edu and Enterprise plans.
  4. Describe a task in plain English.

You can use an API key instead of a ChatGPT account, but the README notes it needs additional setup; billing then runs through your API account rather than your ChatGPT plan.

Fixing the common problems

  • `codex: command not found` — the install location is not on your PATH. Open a new terminal first; with npm, check that your global npm bin directory is on PATH.
  • npm permission errors on Mac or Linux — avoid sudo npm install -g; use a Node version manager or the install script instead.
  • Script blocked on Windows — the -ExecutionPolicy ByPass flag in the official command is there for exactly this; run it in PowerShell, not Command Prompt.

Codex or Claude Code?

Both are terminal agents that read your repo and run commands; they differ in models, pricing and how they delegate work. We compared them head to head in Claude Code vs Codex. If you want neither vendor, see open-source alternatives to Claude Code, or run models on your own machine with our local LLM for coding guide.

Frequently asked questions

How do I install Codex CLI on Windows?+

Codex CLI has a native Windows installer. Open PowerShell and run powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex", which is the official command from the openai/codex README. The ExecutionPolicy flag lets the installer script run without changing your system policy. Alternatively, if Node.js is installed, npm install -g @openai/codex works on Windows too. Open a new terminal afterwards and run codex.

How do I install Codex CLI on Mac?+

You have three official options. Run curl -fsSL https://chatgpt.com/codex/install.sh | sh to use the install script, brew install --cask codex if you use Homebrew, or npm install -g @openai/codex if you already have Node.js. Prebuilt binaries for Apple Silicon and Intel Macs are also published on GitHub Releases. After installing, open a new terminal, run codex and sign in with your ChatGPT account.

Do I need a ChatGPT subscription to use Codex CLI?+

Not strictly, but it is the recommended route. Running codex and choosing Sign in with ChatGPT works with Plus, Pro, Business, Edu and Enterprise plans, and usage counts against your plan. You can use an OpenAI API key instead, which bills per token through your API account, though the README notes that setup requires additional steps. The CLI itself is free and open source under Apache-2.0.

Why does it say codex command not found?+

Your shell cannot find the installed binary, usually because the install location is not on your PATH or the terminal was opened before installing. Close and reopen the terminal first. If you installed with npm, make sure your global npm bin directory is on PATH, and avoid sudo installs on Mac or Linux, which often put binaries in unexpected places. The official install script avoids most of these issues.

Is Codex CLI better than Claude Code?+

Neither is universally better; they suit different setups. Both are terminal coding agents that read your repository, edit files and run commands. They differ in the models they use, how pricing works through each vendor's subscription, and how they handle subagents and configuration. If you already pay for ChatGPT, Codex is the natural start; if you are on a Claude plan, Claude Code is. Comparison benchmarks shift with every model release.

More in Developer Tools

How to Install Codex CLI on Windows, Mac and Linux (2026) — StackPicks — StackPicks