# Save ACF Field Groups as JSON Outside the Theme

> Stores Advanced Custom Fields field groups, post types and options pages as JSON files in wp-content/acf-json, so they survive theme changes and can go into version control.

- Type: PHP
- Runs: Run everywhere
- Category: [Custom Post Types & Fields](https://wpide.com/library/category/post-types/)
- Tags: acf, json, version-control
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/acf-json-sync-folder/

## Code

```php
// Folder for the JSON files.
$wpide_acf_json_dir = WP_CONTENT_DIR . '/acf-json';

add_filter( 'acf/settings/save_json', function () use ( $wpide_acf_json_dir ) {
    if ( ! is_dir( $wpide_acf_json_dir ) && wp_mkdir_p( $wpide_acf_json_dir ) ) {
        // Prevent directory listings.
        file_put_contents( $wpide_acf_json_dir . '/index.php', "<?php\n// Silence is golden.\n" );
    }

    return $wpide_acf_json_dir;
} );

add_filter( 'acf/settings/load_json', function ( $paths ) use ( $wpide_acf_json_dir ) {
    $paths[] = $wpide_acf_json_dir;

    return array_unique( $paths );
} );
```

## Notes

After activating, open each field group and click Update once to write its file. Change $wpide_acf_json_dir to use another folder.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Save ACF Field Groups as JSON Outside the Theme" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
