whatisgithub

What is tinyxml2?

leethomason/tinyxml2 — explained in plain English

Analysis updated 2026-06-26

5,752C++Audience · developerComplexity · 2/5LicenseSetup · easy

In one sentence

TinyXML-2 is a minimal C++ XML library consisting of just one header and one source file, making it easy to drop into any project including game engines and embedded systems where memory and binary size are constrained.

Mindmap

mindmap
  root((TinyXML-2))
    Core
      Read XML files
      Write XML files
      Build trees in code
      Stream output
    Features
      UTF-8 support
      Character entities
      Three whitespace modes
      Error line numbers
    Constraints
      No DTD validation
      No XSLT support
    Use Cases
      Game engines
      Embedded systems
      Config files
    License
      ZLib permissive
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Add XML config file parsing to a C++ game engine by dropping in two files with no additional build system setup.

USE CASE 2

Parse save game data or settings stored in XML format inside a resource-constrained embedded application.

USE CASE 3

Build an XML document from scratch in C++ code and write it to a file or an in-memory string buffer.

USE CASE 4

Stream XML output directly without constructing an in-memory document tree when exporting large datasets.

What is it built with?

C++

How does it compare?

leethomason/tinyxml2pbek/qownnotesslackadays/clipboard
Stars5,7525,7425,774
LanguageC++C++C++
Setup difficultyeasymoderateeasy
Complexity2/53/52/5
Audiencedeveloperwriterdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

No external dependencies, just drop XMLDocument.h and tinyxml2.cpp into your project, works without STL containers, exceptions, or RTTI.

So what is it?

TinyXML-2 is a small C++ library for reading and writing XML files. XML is a text format used to store structured data, with tags and attributes much like HTML. TinyXML-2 reads an XML file and builds it into a tree of objects in memory, which your C++ code can then navigate, modify, and write back out. The entire library is just one header file and one source file, so adding it to a project is as simple as dropping in those two files. It does not require any standard library containers, exception handling, or runtime type information, which makes it particularly suitable for environments with limited resources, such as game engines or embedded systems. The README notes that TinyXML-2 was specifically rewritten from its predecessor to use less memory and fewer memory allocations compared to TinyXML-1. When TinyXML-2 parses a document, it creates an XMLDocument object that owns all the elements, text nodes, attributes, and comments inside it. You access parts of the tree by traversing from the root down through child elements. You can also build an XML document from scratch in code and write it to a file or a memory buffer, or stream XML output directly without constructing a document at all. The library handles UTF-8 text, recognizes standard XML character entities such as ampersand and less-than signs, and supports numeric character references for Unicode code points. It offers three whitespace handling modes: preserve (the default, which keeps spacing inside text but not between elements), collapse (which strips leading and trailing spaces), and pedantic (which records all whitespace including between elements). Error messages include the line number where a parse problem occurred. TinyXML-2 does not support DTD validation or XSLT stylesheets. It is released under the ZLib license, which allows use in both open source and commercial projects.

Copy-paste prompts

Prompt 1
Show me how to add TinyXML-2 to my C++ project and parse a config.xml file to read the text value of a specific element.
Prompt 2
Write C++ code using TinyXML-2 to build an XML document from scratch with nested elements and attributes, then save it to a file.
Prompt 3
How do TinyXML-2 whitespace modes work, what is the difference between preserve, collapse, and pedantic, and when should I use each?
Prompt 4
Parse a UTF-8 XML file with TinyXML-2, walk all child elements of the root node, and print each element name and its text content.
Prompt 5
How do I handle parse errors in TinyXML-2 and get the line number where the XML problem occurred?

Frequently asked questions

What is tinyxml2?

TinyXML-2 is a minimal C++ XML library consisting of just one header and one source file, making it easy to drop into any project including game engines and embedded systems where memory and binary size are constrained.

What language is tinyxml2 written in?

Mainly C++. The stack also includes C++.

How hard is tinyxml2 to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is tinyxml2 for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.