← All work

Figma-to-ACF Code Generator (WP-CLI)

A WP-CLI tool that converts Figma JSON into Tailwind markup and ACF block templates.

Status
Ready for client work
Stack
  • WP-CLI
  • PHP
  • ACF Pro
  • Tailwind CSS
  • Figma

Overview

I built a custom WP-CLI tool that takes structured Figma JSON and generates Tailwind markup and ACF block templates. The goal was to cut down on the repetitive work involved in turning designs into WordPress blocks, giving developers a working starting point instead of having to build everything from scratch.

The problem

Converting Figma designs into WordPress blocks involves a lot of repetitive work. Setting up the markup, applying Tailwind classes, defining ACF fields, and wiring everything together are tasks that come up with almost every block.

Across larger projects, this takes time and can lead to inconsistencies, especially when multiple developers are working on the same codebase.

What I built

I created a WP-CLI command that reads structured Figma JSON and generates the corresponding Tailwind markup and ACF templates.

It was built around our internal WordPress starter theme (Ashlar), which uses ACF Pro and StoutLogic ACF Builder. Since the theme already follows a consistent structure for field definitions and reusable blocks, I used that as the foundation for the generator.

This also makes the output easier to work with AI coding tools. Instead of generating blocks from scratch, they can follow the existing ACF structure and conventions, leaving developers with code they can review, adjust, and integrate into the project.

A simplified example of how the command works (illustrative only):

illustrative example
$ wp acf:generate --from=figma.json --block=hero
# → theme/blocks/hero/block.json
# → theme/blocks/hero/hero.php
# → theme/blocks/hero/template.php
$ wp acf:generate --from=figma.json --block=hero --dry-run

Tech stack

WP-CLI, PHP, ACF Pro, StoutLogic ACF Builder, Tailwind CSS, and Figma.

Outcome

The generator is built and ready to be used on upcoming client projects. It provides a starting point for building WordPress blocks while keeping the generated code aligned with the existing theme structure.

Takeaway

I found that having a consistent structure in the starter theme makes code generation much more practical. The generated code doesn’t have to be perfect or production-ready out of the box. It just needs to follow the project’s conventions well enough that developers can pick it up, make adjustments, and move forward without starting from scratch.