Typograms
https://github.com/google/typograms/

Overview

Typograms (typographic diagrams) is a lightweight image format (text/typogram) useful for defining simple diagrams in technical documentation.

Like markdown, typograms is heavily inspired by pre-existing conventions found in ASCII diagrams. A small set of primitives and rules to connect them is defined, which you can use to build larger diagrams.

Typograms optimizes for editability and portability (e.g. plain text is easy to maintain, change, store and transmit), at the cost of expressivity (e.g. SVG is more expressive) and ergonomics (e.g. higher level tools produce diagrams faster).

A comparison with related work is available below.

A JS renderer is available that allows you use to use it in browsers.

Installation

To get started, the easiest way to use typograms is to link from our CDN:
      
<body>
  <script src="https://google.github.io/typograms/typograms.js"></script>
  <script type="text/typogram">
+----+
|    |---> My first diagram!
+----+
  </script>
</body>
      
    
From there, you can download the library directly to serve yourself. You can also use it as a command line tool or a node library: https://github.com/google/typograms

Primitives

Typograms are composed of primitives and connectors that combine them: pipes (| - _ \ / : ~), dots arrows (> ^ * o # v < ) and Connectors (+ . -).

By putting them together, you can form a lot of different diagrams.

Pipes

+--+-++-||||-+-|/\\/+--++--++\/\/||||+--+-++-|-+-+--++--+\//\/\+++/\.--.-..-||||-.-|/\\/.--..--..\/\/||||'--'-''-|-'-'--''--'\//\/\'../\______________\/|||||__|_||_|_|_/__\\__/\//\/\\_/||/\+~~+~++~::::~+~:::::+~~+~++~:~+~/\/\\/\/-..--..-..-.-.'--''-''-''-'

Dots

o-o*-o#-o|||\/\/\/\/\/\/o-**-*#-*o*#oooo****####o-#*-##-#|||/\/\/\/\/\/\

Arrows

|^^^/\-><-v|/\vv->||<-->oo<-->**<-->##<--_*o#^^^^^||||||||||vvvvv-_*o#----\||/^||^\/^^v||v/||\vv/\----

Text

Anythingbetweendoublequotesisrenderedastext!

Examples

Protocols

+-----++-----+|A||B|+--+--++--+--+|foo||----------------->||hello||----------------->|--+|world||promptstheuser|<-----------------|--+||--+----+--

Mocks

.------------------------.|.----------------------.|||https://example.com|||'----------------------'||______________________|||||||Welcome!||||||||||||.----------------.|||||username|||||'----------------'||||.----------------.|||||*******|||||'----------------'||||||||.----------------.|||||Sign-up|||||'----------------'|||||||+----------------------+|.------------------------.

Architecture

Components

SenderMailServerReceiver_____.---------.SMTP|=====|POP.---------.||-------------->||<--------------|||Alice||||Bob|+---------+|o|+---------+///_____\\\|_____|///_____\\\'-------------''-------------'+---------------------+|To:bob@bar.com||From:alice@foo.com||Body:Hi!|+---------------------+

Layers

.---..---..---..---..---..---.'---''---''---''---''---''---'||||||vv|v|v.------------.|.-----------.|.-----.|Filesystem|||Scheduler|||MMU|'------------'|'-----------'|'-----'||||v||v.----.||.~~~~~~~~~.|IO|<----'|:Network:'----'|'~~~~~~~~~'|||vvv.---------------------------------------.|HAL|'---------------------------------------'

Tables

+-----+---------+---------+~~~~~~+----------+|ID|First|Last::Lang|+-----+---------+---------+~~~~~~+----------+|1|Joe|Doe::en-US|+-----+---------+---------+~~~~~~+----------+|2|Rick|Russel::en-US|+-----+---------+---------+~~~~~~+----------+::::::::::::+-----+---------+---------+~~~~~~+----------+|999|Anna|Merkle::pt-BR|+-----+---------+---------+~~~~~~+----------+

Flow charts

.-------.+|START|/\'---+---'/\+-+---------+-+___________|.-----./\||COMPLEX||/\v|END|<---+CHOICE+--->||||->+PREPARATION+->X+-------+'-----'\/||PROCESS||\___________//INPUT/\/+-+---------+-++-------+\/|+v^+---------++----+----+|PROCESS|------------>|PROCESS|<-----x+---------++---------+

Trees

+++--1.--1/1/\|+--+.--++/\+---+---+|+--2|'--2/\2++||--+--++/\/\+-+-++-+-+|+--3|.--3\/3/\/\||||+--+'--++12341234+--4'--4\4Linux+--Android+--Debian|+--Ubuntu||+--Lubuntu||+--Kubuntu||`--Xubuntu|`--Mint+--Centos`--FedoraXY/\/\AY->XC/\/\BCAB

Shapes

Big Shapes

+---------+++------+.-----.+~~~~~++----++----+\//\\\||::/\/\\//\\\||::/\||\//\\\||::\/||\//\\\||::\/\/++---------++------+'-----'+~~~~~++----++----+

Small Shapes

_________.---.__+-++-+/\/\\/+\//\+-++-++-+||++||_//\\\__//__\\//_\+/\+-+/_/\_\'---'++|__||_|+-++-++----+

Overlaps and intersections

.---..---..---..---..---.||||||||||.--+---+--..--+---+--..--||--..--++--..----|---.||||||||||||||'--+---+--''--+---+--''--||--''--++--''--|-----'||||||||||'---''---''---''---''---'

Grids

Big grids

+----++----+/\/\.-----+-----+-----.++----++----+||||.-----+-----+-----+-----+\/\/\||||/////+----++----+++-----+-----+-----++-----+-----+-----+-----+/\/\/||||/////++----++----+||||+-----+-----+-----+-----+\/\/\+-----+-----+-----+/////+----++----++||||+-----+-----+-----+-----+\/\/||||/////+----++----+'-----+-----+-----''-----+-----+-----+-----+

Small grids

______.---+---+---+---+---..---+---+---+---..---..---.___/\___/\||||||/\/\/\/\/|+---+|/\___/\___/+---+---+---+---+---++---+---+---+---++---++---+\___/\___/\||||||\/\/\/\/\|+---+|/\___/\___/+---+---+---+---+---++---+---+---+---++---++---+\___/\___/\||||||/\/\/\/\/|+---+|\___/\___/'---+---+---+---+---''---+---+---+---''---''---'

Dot grids

ooooo*****o***oooo***.*...ooooo******ooo*oooo****.o...ooooo*****oooo*ooooo*****.....ooooo********oooooo****.oo*.ooooo*****ooo**ooo***.oooo

Time series

85.6778.2070.7363.2755.8048.3340.8733.4025.9318.4711.00201120122013201420152016E+-------------------------*--+E|oD|-------------------*--*--|--*D|oo|oC|-------------*--*||||C|oo||||B|-------*--*||||||B|oo||||||A+-*--*--+--+--+--+--+--+--+--+A+-o--o--|--|--|--|--|--|--|--|51015202530354045505101520253035404550Uin:.------------------------:|:|*---'~~~~~~~~~~~~~~~~~~~~~~~~UdcUdc_OK:.---------------------:/:::/::*---'~~~~:~~~~~~~:~~~~~~~~~~~:<----->:500ms:Cpu.Qon:~~~~~~~~~~~~~~~~.-----------:|Inactive:Active|*----------------'~~~~~~~~~~~

Chips

+-----++----[PWR]-------------------|USB|--+|+-----+||GND/RST2[][]||MOSI2/SCK2[][]A5/SCL[]|C5|5V/MISO2[][]A4/SDA[]|C4|AREF[]||GND[]||[]N/CSCK/13[]|B5|[]IOREFMISO/12[]|.|[]RSTMOSI/11[]~|.|[]3V3+---+10[]~|.|[]5v|A|9[]~|.|[]GND-|R|-8[]|B0|[]GND-|D|-||[]Vin-|U|-7[]|D7|-|I|-6[]~|.|[]A0-|N|-5[]~|.|[]A1-|O|-4[]|.|[]A2+---+INT1/3[]~|.|[]A3INT0/2[]|.|[]A4/SDARSTSCKMISOTX>1[]|.|[]A5/SCL[][][]RX<0[]|D0|[][][]||UNO_R3GNDMOSI5V___________||_________________________|

Circuits

+10-15V___0,047R*---------o-----o-|___|-o--o---------o----o-------.+||||||||-===-_|_||.+.|||-===-.-.||||2k2|||-===-470|+||||||_|_-|uF|'--.|'+'.+.|\/LED+---------o|6|7|81k|||-+-___|___.-+----+--+--.||||--||'+'||-||1||/BC|GND|+------o--+547|||||`>|||.+.||.-------+|220R||o----||-+IRF9Z34|||||||+->||MC34063|`+'|||-+||||||BYV29-12V6|||'----'o--|<-o----o--XOUT6000micro-|+||2|||Farad,40V___|_____||--oC|||Capacitor~~~~~||GND30uHC||---470|||31nFC||###uF|||-------||--.|||+|'-----+----+-'|GND|GND|5|4|||||'-------------o-------------o||___|`-------------*------/\/\/------------o--|___|-'2k|1k0.+.||5k6+3k3||inSerie'+'|GND

Mindmaps

.-->Alpha/.---->InitialReleasePlanning*-------./\\/'--->Patch1Initialresearch\/\*\/'-->Patch2\\/--------->Beta\\/\oo_______\.---.*-----./\'------>||'------o->.Release.`---'o\_______/ooo\/\\\.--'\\\/\\'----+->Pushbacks/\\\/|\\'---->Setbacks/|\\V/|\'----->ReceptionTeam/|\v/|\Worklaod/.'-->>CareerchangeV/PTO/VBug

Scribbles

Lines with decorations

+----+o|o**.----------.*-+---.'-*-+-|v^\/|.--------.||'--->+----+->*<-/.-+->*<-o--+|'------>||<-'*---+|<----->|+----'|^\'---------'||__|v*----------'.--->FABCD/*-------*-----*---*----*----->E\^\\/'--->GB-->C-+

Line ends

o-o*-o//*ooooo****oooo****oooo****o-**-*vv^^||||||||\\\\\\\\////////o->*->*o||o*vo*vo*vo*vo*vo*vo-*-^^*o||^^^^^^^||^^vv*o^^^^||||\\\\\\\\///////*o*o^^o*vo*vo*vo*vo*vo*v<-o<-*<-><--o-*->--*<-o<-->o->*\|/\vvv/\|/v+-----+vvvv->||<-->*<-^+-----+^^^^/^^^\/|\/|\

Graph with small nodes

A1248*-->o<-->o<--o---------.o^^|^||v|o<->*<-->o--->*-->o-->o<-->*3B5C67D

Graphic diagrams

03P*Eye/^/*-------*+y\+)\/Reflection1/|2/|^\\\v*-+-----*||v0\v3--------*--------||4||7|*----\-----*|*-----|-*+----->+x/vX\o|/|///o\/\*-------*v/\/\56+zv1*------------------*v2o-----o

Work in Progress

This is a list of constructions that are currently looking into supporting.

UT8 Diagram Characters Are Off

||||||https://rp.example||||https://rp.example||||||||||||||||||||Welcometomywebsite!||||Welcometomywebsite!|||||||||||||||||||++||++|||Chooseanaccount||||Sign-intorp.example||||tosign-intorp.example||||withidp.example?|||||||||||||||||||||:)|JohnDoe|||||:)|JohnDoe||||john@email.com||||john@email.com|||||||||||||:]|JohnDoe||||||||john.doe@work.com|||||ContinueasJohn|||||||||||||||

Triangles connected without + aren't pointy

/\

Diagonals don't join with underscores

___/\

Text detection gets confused

-----|||

Small curved steps

-.__.-

Parenthesis and spheres

\/||()()/\||__.-..-.||/\(__)(1)||'-'+)(+'-'\/

Diagonal Side-way Arrows

\/\/><<>><<>/\/\

Related Work

The closest work to typograms is svgbob: it renders diagrams from ASCII and works in browsers (through a webassembly port which spits out SVGs). It supports a similar set of features (with the notable exception of its support for circle drawing) and picks a similar set of typographic conventions (with the notable exception of text rendering). It is well-specified. I ran into enough challenges with (a) the text rendering and (b) running in the browser through the webassembly port that motivated me to write an ASCII diagram renderer in JS (svgbob is written in rust), but is otherwise a perfectly valid (more mature) alternative.

From there, there is a series of projects that rendered images from ASCII diagrams but weren't either (a) particularly good to be used in isolation (i.e. just diagrams) or (b) on webpages (i.e. running natively in browsers): asciitosvg, ditaa and markdeep (and the go port GoAT) most notably.

Unlike libraries like mermaid, typograms are defined typographically (WYSWYG), rather than semantically (a transformation from a high level description to graphics), which picks a different trade-off: it gives you more control over the rendering (expressivity) at the cost of making you type more (productivity).

Specification