Field groups as code

ACF JSON to PHP converter

Paste an exported ACF field group and get ready-to-register PHP. Choose the hook and array style, strip timestamps, copy or download.

Options

          

Quick answer: To register ACF fields in PHP, export a field group as JSON, paste it above and copy the generated acf_add_local_field_group() code into your theme or plugin inside an acf/include_fields hook (ACF 6.1 and later) or acf/init. Registering fields in code keeps them in version control.

Why register field groups in PHP?

Code-registered field groups live in your repository, deploy with your theme and cannot be changed from the admin by accident. They also load without a database query for the group definition.

Which hook?

ACF 6.1 and later fire acf/include_fields for local field groups, which is the recommended hook. Older versions used acf/init. Both work on current ACF, so pick the one that matches the oldest version you support.

Local JSON is another option

If you only want version control, ACF can also save field groups as JSON files in an acf-json folder inside your theme, with no PHP conversion needed. Use PHP when you want the definition to live in code you can edit and review.

Frequently asked questions

How do I export a field group from ACF?

In the WordPress admin go to ACF, then Tools, choose Export Field Groups, select your groups and use Generate PHP or Export File. This tool converts the JSON export.

Can I paste several field groups?

Yes. Paste an array of field group objects and each one becomes its own acf_add_local_field_group() call.

Why is the modified timestamp removed?

It changes every time the group is saved and creates noisy diffs in version control. You can untick the option to keep it.

Does the converter send my JSON anywhere?

No. The conversion runs in your browser and nothing is uploaded.

Does registering in PHP replace the database copy?

A field group with the same key registered in PHP is used instead of the database version, and the admin shows it as read only unless you sync it.