Overview
Exports field groups, post types, taxonomies, and options pages to a JSON file.
Description
Exports ACF items to a JSON file, replicating the functionality of the export tool in the WordPress admin. You can export all items or filter by specific types and keys.
Options
wp acf json export [--field-groups=<keys>] [--post-types=<keys>] [--taxonomies=<keys>] [--options-pages=<keys>] [--dir=<directory>] [--stdout]
--field-groups=<keys>
(string) Optional. Export specific field groups by key or label, comma separated.
--post-types=<keys>
(string) Optional. Export specific post types by key or label, comma separated.
--taxonomies=<keys>
(string) Optional. Export specific taxonomies by key or label, comma separated.
--options-pages=<keys>
(string) Optional. Export specific options pages by key or label, comma separated. Requires ACF PRO.
--dir=<directory>
(string) Required (unless using --stdout). Directory path to write the JSON file to.
--stdout
(flag) Optional. Output JSON to stdout instead of writing to a file. Useful for piping to other commands.
Examples
Export all items to a directory
$ wp acf json export --dir=./exports/
Success: Exported 15 item(s) to ./exports/acf-export-2025-01-01.json
Export specific field groups by key
$ wp acf json export --field-groups=group_abc123,group_def456 --dir=./
Export a field group by label
$ wp acf json export --field-groups="My Field Group" --dir=./
Export multiple item types
$ wp acf json export --field-groups=group_abc123 --post-types=post_type_def456 --dir=./exports/
Export to stdout for piping
# Output raw JSON
$ wp acf json export --stdout
# Pretty print with jq
$ wp acf json export --field-groups=group_abc123 --stdout | jq .
# Pipe to another command
$ wp acf json export --stdout > backup.json
Backup before deployment
# Export current state before sync
$ wp acf json export --dir=./backups/
$ wp acf json sync
Return
When using --dir, the command creates a file named acf-export-YYYY-MM-DD.json in the specified directory and outputs a success message with the item count and file path.
When using --stdout, the JSON is output directly to the terminal.
Notes
- You must specify either
--diror--stdout - Cannot use both
--dirand--stdouttogether - If no filter options are provided, all items across all types are exported
- Items can be specified by their ACF key (e.g.,
group_abc123) or by their title/label - The export includes all fields for field groups
- Options pages require ACF PRO
Errors
| Error | Cause |
|---|---|
| You must specify –dir or –stdout | Neither output option was provided |
| Cannot specify both –dir and –stdout | Both output options were provided |
| Directory not found | The specified directory does not exist |
| Directory is not writable | The directory exists but cannot be written to |
| No items found to export | No items match the specified filters |
Supercharge Your Website With Premium Features Using ACF PRO
Speed up your workflow and unlock features to better develop websites using ACF Blocks and Options Pages, with the Flexible Content, Repeater, Clone, Gallery Fields & More.
Related
- CLI: wp acf json import
- CLI: wp acf json sync
- CLI: wp acf json status
- CLI: wp acf json
- Features: Local JSON