Skip to main content
The Tailwind CSS CLI is a standalone tool that compiles your Tailwind CSS files without requiring any build tool configuration. It’s the simplest way to get started with Tailwind CSS.

Installation

Install the @tailwindcss/cli package globally or in your project:

Basic Usage

The CLI processes your CSS files and generates the output with all Tailwind utilities:
If you don’t specify an input file, the CLI will use a default input that imports Tailwind CSS:

Watch Mode

Use watch mode to automatically rebuild your CSS when files change:
The watch mode monitors your content files and rebuilds the CSS whenever it detects changes. By default, it stops when stdin is closed. Use --watch=always to keep watching even when stdin closes:

Input and Output

Using stdin and stdout

You can pipe CSS through the CLI using stdin and stdout:
Or use the - flag explicitly:

Specifying Files

Use the --input and --output flags to specify file paths:
You can also use the short aliases:

Optimization

Minification

Optimize and minify your output for production:
This will remove unnecessary whitespace and optimize the CSS using Lightning CSS.

Optimization Without Minification

If you want to optimize the CSS without minifying it:

Source Maps

Inline Source Maps

Generate inline source maps for debugging:

External Source Maps

Write source maps to a separate file:
The CLI will add a source map comment to your CSS file pointing to the external map file.

Working Directory

Specify the current working directory for relative paths:

Command Reference

Options

string
Input CSS file path. Use - for stdin. Defaults to a built-in CSS file that imports Tailwind.Alias: -i
string
Output CSS file path. Use - for stdout.Alias: -oDefault: - (stdout)
boolean | 'always'
Watch for changes and rebuild as needed. Use always to keep watching when stdin is closed.Alias: -w
boolean
Optimize and minify the output CSS.Alias: -m
boolean
Optimize the output without minifying.
string
The current working directory for resolving relative paths.Default: . (current directory)
boolean | string
Generate a source map. Pass true for inline maps or a file path for external maps.Default: false
boolean
Display usage information.Alias: -h

Examples

Development Build

Build with watch mode and source maps for development:

Production Build

Build with minification for production:

Using with npm scripts

Add scripts to your package.json:
Then run:

How It Works

The CLI performs the following steps:
  1. Reads input - Processes the input CSS file (or stdin)
  2. Scans content - Automatically scans your project files for Tailwind class names
  3. Compiles CSS - Generates CSS for all detected utilities
  4. Optimizes - Optionally minifies and optimizes the output
  5. Writes output - Saves to the output file (or stdout)
In watch mode, the CLI monitors file changes and triggers incremental rebuilds when:
  • Your input CSS file changes (full rebuild)
  • Your configuration or plugin files change (full rebuild)
  • Your content files change (incremental rebuild)
The CLI uses the Rust-based scanner from @tailwindcss/oxide for extremely fast candidate detection across your entire project.