---
name: json-out-dir
description: Directory to store JSON plan files generated from plans via show -json.
type: string
env:
  - TG_JSON_OUT_DIR
---

import { Aside } from '@astrojs/starlight/components';

<Aside type="note">

This flag only does anything when used with the `--all` flag for stack runs. It does nothing in single-unit runs.

To generate JSON plan files for a single unit run, use the standard OpenTofu/Terraform [-out flag](https://opentofu.org/docs/cli/commands/plan) like so:

```bash
terragrunt run -- plan -out=/tmp/tfplan
```

```bash
terragrunt run -- show -json /tmp/tfplan > /tmp/tfplan.json
```

</Aside>

Generates machine-readable plan outputs per unit as `tfplan.json` by invoking `show -json` after the plan is created.

- Requires a plan to exist (e.g. created with `--out-dir`).
- If the directory does not exist, Terragrunt creates it.
- Relative paths are resolved against the root working directory, and Terragrunt mirrors the unit path under this directory (e.g. `<json-out-dir>/<relative-unit-path>/tfplan.json`).

Examples:

```bash
# Create native plan files and JSON plans for all units
terragrunt run --all --out-dir /tmp/all --json-out-dir /tmp/all plan

# Or store JSON plans separately
terragrunt run --all --out-dir /tmp/plan --json-out-dir /tmp/json plan
```

See the [Stacks](/features/stacks/stack-operations#saving-opentofuterraform-plan-output) docs for more usage examples.


