{"slug": "ai-generated-ascii-diagrams", "title": "AI-generated ASCII diagrams", "summary": "John D. Cook, a mathematician and blogger, tested Anthropic's Claude AI's ability to generate ASCII diagrams, finding that the first attempt to reproduce a graph from his post on the graph imbalance theorem produced a clear diagram, while a more complex network yielded a hard-to-read result. Cook notes that ASCII diagrams are useful for embedding in plain text files like source code or markdown, and AI generation removes the tedium of creating them manually.", "body_md": "I like AI-generated ASCII diagrams. Because nobody would ask AI to generate ASCII diagrams, and so, it’s congruous. I like incongruity [1].\n\nAside from the incongruity of using a gazillion-parameter neural network to make 1970’s style ASCII art, ASCII diagrams have some uses. They’re absolutely tiny compared to image files. But more importantly they can be inserted into plain text files, such as source code or markdown. A diagram embedded directly into a source file cannot become separated from the code.\n\nASCII diagrams are tedious to create, though there are [tools](https://www.johndcook.com/blog/2016/06/15/ascii-art-diagrams-in-emacs-org-mode/) to mitigate the tedium. But if an AI can generate the diagram, the tedium goes away.\n\nI was curious how well Claude could create ASCII diagrams, so I tried a few examples. I hope these render well in whatever format you’re reading this post. They look fine for me previewing the post in a browser. I expect they might not turn out so well in an RSS reader.\n\nI asked it to reproduce the graphs from my recently post on the [graph imbalance theorem](https://www.johndcook.com/blog/2026/08/18/the-imbalance-theorem/) and the first diagram turned out nicely.\n\n```\n                 +-------+                                +-------+\n                 |   A   |--------------------------------|   B   |\n                 +-------+                                +-------+\n                     |                                        |\n                     |                                        |\n   ------------------|------------------             ---------|---------\n   |        |        |        |        |             |        |        |\n   |        |        |        |        |             |        |        |\n+-----+  +-----+  +-----+  +-----+  +-----+       +-----+  +-----+  +-----+\n| a0  |  | a1  |  | a2  |  | a3  |  | a4  |       | b0  |  | b1  |  | b2  |\n+-----+  +-----+  +-----+  +-----+  +-----+       +-----+  +-----+  +-----+\n```\n\nThe second network is more complicated and so the corresponding ASCII diagram is hard to read.\n\n```\n   +----------------------------------------------------------------+\n   |                                                                |\n   |+-----------------------------------------------+               |\n   ||                                               |               |\n   ||+-------------------------------+              |               |\n  +-------+       +-------+       +-------+       +-------+       +-------+\n  |  R1   |-------|  R2   |-------|  R3   |-------|  R4   |-------|  R5   |\n  +-------+       +-------+       +-------+       +-------+       +-------+\n      |             | | |          |   |           |   |           |  |  |\n     ++             | | |          |   |           |   |           |  |  |\n     | +---------------------------+   |           |   |           |  |  |\n     | |            ++| |              |           |   |           |  |  |\n     | |             || +--------------+           |   |           |  |  |\n     | |             || |  +---------------------------------------+  |  |\n     | |             |+-|--|-------------+         |   |              |  |\n     | |             |  |  |             |  +------+   |              |  |\n     | |             |  |  |             |  |  +----------------------+  |\n     | |             |  +--|-------------|--|--|-------------+           |\n     | |             |  |  |             |  |  |       +-----|--+        |\n     | |             |  |  |             |  |  |             |  |  +-----+\n     | |             |  |  |             |  |  |             |  |  |\n  +-------+         +-------+           +-------+           +-------+\n  |  G1   |         |  B1   |           |  B2   |           |  B3   |\n  +-------+         +-------+           +-------+           +-------+\n```\n\nFor a third example, here is a fairly complicated diagram that nevertheless lends itself to a readable ASCII diagram. It’s a [Feistel network](https://www.johndcook.com/blog/2020/04/04/feistel-networks/) diagram for DES encryption.\n\n```\n   +-------------+                    +-------------+\n   |   L(i-1)    |                    |   R(i-1)    |--------\n   +-------------+                    +-------------+       |\n          |                                  |              |\n          |                                  |              |\n          |                      +-----------------------+  |\n          |                      |   E (expand 32->48)   |  |\n          |                      +-----------------------+  |\n          |                                  |              |\n          |                      +-----------------------+  |\n          |                      |     XOR with K(i)     |  |\n          |                      +-----------------------+  |\n          |                                  |              |\n          |                      +-----------------------+  |\n          |                      |    S-boxes S1..S8     |  |\n          |                      +-----------------------+  |\n          |                                  |              |\n          |                      +-----------------------+  |\n          |                      |    P (permutation)    |  |\n          |                      +-----------------------+  |\n          |                                  |              |\n          |                                  |              |\n          |            +-------+             |              |\n          +------------|  XOR  |-------------+              |\n                       +-------+                            |\n                           |                                |\n          +----------------|--------------------------------+\n          |                +------------------+\n          |                                   |\n   +-------------+                    +-------------+\n   |    L(i)     |                    |    R(i)     |\n   +-------------+                    +-------------+\n```\n\n## Related posts\n\n[1] See Christian Wolff’s discussion of dogs playing poker in The Accountant (2016).", "url": "https://wpnews.pro/news/ai-generated-ascii-diagrams", "canonical_source": "https://www.johndcook.com/blog/2026/08/20/ai-generated-ascii-diagrams/", "published_at": "2026-08-20 13:48:43+00:00", "updated_at": "2026-08-20 14:14:35.196369+00:00", "lang": "en", "topics": ["generative-ai", "ai-tools"], "entities": ["John D. Cook", "Anthropic", "Claude"], "alternates": {"html": "https://wpnews.pro/news/ai-generated-ascii-diagrams", "markdown": "https://wpnews.pro/news/ai-generated-ascii-diagrams.md", "text": "https://wpnews.pro/news/ai-generated-ascii-diagrams.txt", "jsonld": "https://wpnews.pro/news/ai-generated-ascii-diagrams.jsonld"}}