---
layout: docs
page_title: 'nomad fmt command reference'
description: |
  The `nomad fmt` commands rewrites Nomad configuration and job specification
   files to canonical format. Use this command to improve readability and enforce consistency of style in Nomad files.
---

# `nomad fmt` command reference

The `nomad fmt` command rewrites Nomad configuration and job specification files
to canonical format. Use this command to improve readability and enforce
consistency of style in Nomad files.

## Usage

```plaintext
nomad fmt [options] paths ...
```

If a path is a directory, the command recursively formats all files with
`.nomad` and `.hcl` extensions in the directory. If you provide a single dash
(-) as an argument, the `nomad fmt` command reads from standard input and
writes the processed text to standard output.

The `nomad fmt` command checks the syntax against
[HCL2](https://github.com/hashicorp/hcl/blob/hcl2/README.md), the second
generation of Hashicorp Configuration Language. Running this command with
deprecated HCL1 job specification results in errors.

## Options

- `-check`: Check if the files are valid HCL files. If not, exit status of the
  command will be 1 and the incorrect files will not be formatted. This flag
  overrides any `-write` flag value.
- `-list`: List the files which contain formatting inconsistencies. Defaults to
  `-list=true`.
- `-recursive`: Process files in subdirectories. By default, only the given (or
	current) directory is processed.
- `-write`: Overwrite the input files. Defaults to `-write=true`.

## Examples

```shell-session
$ cat agent.hcl
server {
    enabled = true
  bootstrap_expect = 1
}

client {
  enabled = true
}
```

```shell-session
$ nomad fmt
agent.hcl
```

```shell-session
$ cat agent.hcl
server {
  enabled          = true
  bootstrap_expect = 1
}

client {
  enabled = true
}
```
