How to generate block ID for use in post_content JSON data

Elliot Condon of ACF notes that ACF block ID behavior could be better documented, but here’s what I know through my own testing and reading of the documentation:

ACF assigns a new block ID when you first save an ACF block within a post. If you update the block data, such as if you change the block settings, the ID stays the same.

If you create a new post and add an ACF block of the same type, the new block gets a unique block ID.

However, this ACF block ID can be duplicated in some cases, so you can’t assume that it’s unique across your entire site:
https://github.com/AdvancedCustomFields/acf/issues/301

The block ID seems to only exist within wp_posts.

When I search wp_posts and wp_postmeta for the block_### ID or even just the ### portion of the ID, the only matching results are from the wp_post entry where the block was saved.

In the ACF “Blocks” documentation, the “Where is block data saved?” section doesn’t specifically explain how ACF block IDs work, but ACF notes that “WordPress saves block data as HTML comments in the post_content. ACF blocks follow suit and save their data as a JSON object within that HTML comment.”

If you’re looking to retrieve data from your blocks, then in their answer to “Can I load values from other blocks?”, ACF recommends that you “load the post_content of a given post, and then parse the blocks using the parse_blocks() function.”

Does that help?