Okay, you're looking for a command-line tool on Linux that takes a text file written in a specialized language (a DSL) and generates an image file of a diagram. This is a common need, and there are several excellent tools available.
Here are the most popular and capable ones:
Graphviz
What it is: A powerful graph visualization software that takes descriptions of graphs in a simple text language called DOT. It's excellent for drawing abstract graphs, network diagrams, hierarchies (like organization charts or directory structures), and flowcharts (though flowcharts can sometimes require more effort than tools specifically designed for them).
DSL: DOT language (.dot files). It describes nodes and edges between them.
How it works (CLI): You typically use commands like dot, neato, fdp, sfdp, etc., depending on the desired layout algorithm.
Example:
input.dot:
digraph MyFlow {
A [shape=box];
B [shape=circle];
A -> B;
B -> C [label="Process Data"];
}
Command: dot -Tpng input.dot -o output.png (generates a PNG image)
You can replace png with svg, pdf, jpg, etc.
Pros: Very mature, highly flexible, powerful layout algorithms, standard tool for graph visualization.
Cons: The DOT language can sometimes be verbose for complex diagrams or flowcharts compared to more specialized tools.
PlantUML
What it is: A tool that allows you to quickly write various types of UML diagrams (sequence, class, state, activity, component, deployment, object, timing), as well as other non-UML diagrams like Gantt charts, mind maps, WBS (Work Breakdown Structure), and even network diagrams (using C4 model or similar). Its syntax is generally considered very readable and quick to write.
DSL: PlantUML syntax (usually in files with .puml or .plantuml extensions). Diagrams are enclosed in @startuml/@enduml.
How it works (CLI): It's a Java-based tool. You run the plantuml command (often a wrapper script) with the input file(s).
Example:
sequence.puml:
@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
Alice -> Bob: Another request
Alice <-- Bob: Another response
@enduml
Command: plantuml sequence.puml (often generates sequence.png in the same directory by default).
You can specify output format and directory using options. Requires Java Runtime Environment (JRE).
Pros: Excellent and easy-to-read syntax for many common diagram types (especially sequence and UML), supports a wide variety of diagrams, integrates well with documentation tools (like AsciiDoc, Markdown).
Cons: Requires Java, less flexible than Graphviz for highly custom or unusual graph layouts.
Mermaid
What it is: A JavaScript-based diagramming tool often used for integrating diagrams into web pages (like Markdown previews). However, it has a robust CLI tool. It supports flowcharts, sequence diagrams, Gantt charts, class diagrams, state diagrams, entity-relationship diagrams, user journeys, and more. Its syntax is designed to be easy for humans to read and write.
DSL: Mermaid syntax (.mmd files). Diagrams start with keywords like graph, sequenceDiagram, gantt, etc.
How it works (CLI): You need Node.js installed, and then you install the mermaid.cli package (or similar). The command is typically mmdc.
Example:
flowchart.mmd:
graph TD
A[Christmas] -->|Get money| B(Go shopping)
B --> C{Let me think}
C -->|One| D[Laptop]
C -->|Two| E[iPhone]
C -->|Three| F[fa:fa-car Car]
Command: mmdc -i flowchart.mmd -o flowchart.png
Pros: Very simple and intuitive syntax for common diagrams, integrates well with Markdown, actively developed.
Cons: Requires Node.js, layout options are generally less powerful than Graphviz, CLI tool requires separate npm installation.
Other Notable Mentions:
Ditaa: (DIagrams Through Ascii Art) Converts ASCII art diagrams into pixel-based diagrams. The "DSL" is essentially well-formed ASCII art. Requires Java.
Mscgen / Xmsc / Sdiag: Tools specifically designed for Message Sequence Charts (MSC).
Blockdiag Family (blockdiag, seqdiag, actdiag, nwdiag, rackdiag): Python-based tools using specific, simple DSLs for block diagrams, sequence diagrams, activity diagrams, network diagrams, and rack diagrams.
How to Choose:
If your primary need is arbitrary graphs, network maps, or complex hierarchies with precise layout control: Graphviz is often the best choice.
If you frequently create UML diagrams (especially sequence diagrams), mind maps, Gantt charts, or other standard software diagrams and want an easy-to-read syntax: PlantUML is excellent.
If you want the simplest syntax for common diagrams (flowcharts, sequence, etc.) and might integrate with web-based tools or Markdown: Mermaid is a great option, provided you have Node.js.
All these tools are available in standard Linux repositories (except maybe mermaid.cli which is npm-based) and can be easily installed using your distribution's package manager (apt, yum, dnf, pacman, etc.).