whatisgithub

What is gravitasml?

significant-gravitas/gravitasml — explained in plain English

Analysis updated 2026-05-18

37PythonAudience · developerComplexity · 2/5LicenseSetup · easy

In one sentence

A tiny, secure Python parser that turns simple tag-based markup, especially LLM output, into Python dictionaries without any risky XML features.

Mindmap

mindmap
  root((GravitasML))
    What it does
      Parse tags to dicts
      Nested and repeated tags
      Optional raw text blocks
    Tech stack
      Python
      Pydantic
    Use cases
      Parse LLM output
      Safe config formats
      Structured data extraction
    Audience
      AI app developers
      Python developers

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

Parse tag-based text generated by an AI model into a Python dictionary safely.

USE CASE 2

Convert nested markup directly into a validated Pydantic model.

USE CASE 3

Extract structured data from a controlled, simple markup format without a full XML library.

USE CASE 4

Preserve a block of raw content untouched using the no_parse filter while parsing the rest.

What is it built with?

PythonPydantic

How does it compare?

significant-gravitas/gravitasmlt0ddc3by/claude-for-customer-successuseneospark/awesome-gpt-image-2
Stars373737
LanguagePythonPythonPython
Setup difficultyeasymoderateeasy
Complexity2/53/51/5
Audiencedeveloperpm founderdesigner

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

How do you get it running?

Difficulty · easy Time to first run · 5min
Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

So what is it?

GravitasML is a small Python library for parsing simple tag-based markup into Python dictionaries. It was built by the AutoGPT team to handle structured text that AI language models produce, where the output uses XML-style tags to organize data but does not need the full complexity or security risks of a proper XML parser. The main reason to use it instead of a standard XML library is security. Full XML parsers support features like entity expansion and external document references that can be exploited to crash a program or extract data from a server. GravitasML deliberately omits all of those features, so it is safe to run on untrusted output from an AI model or any other source you do not fully control. The library works in two steps: it first breaks the markup text into tokens, then assembles those tokens into a tree and converts the tree to a plain Python dictionary. Nested tags become nested dictionaries. Repeated tags at the same level become a list automatically. Tag names with spaces are normalized to use underscores and lowercase letters. If a section of markup should be kept as a raw string rather than parsed further, you can add a filter marker to the opening tag to suppress parsing for that block. You can also tell the library to convert the parsed result directly into a Pydantic model, which adds field validation on top of the basic parsing. The library does not support tag attributes, self-closing tags, XML namespaces, or generating markup. It is intentionally limited to keep the codebase small and focused on the one task it is designed for.

Copy-paste prompts

Prompt 1
Show me how to install gravitasml and parse a simple tag string into a Python dictionary.
Prompt 2
Help me convert nested markup from an LLM response into a Pydantic model using gravitasml.
Prompt 3
Explain how gravitasml handles repeated tags and turns them into lists.
Prompt 4
How do I use the no_parse filter in gravitasml to keep a block of HTML as a raw string?

Frequently asked questions

What is gravitasml?

A tiny, secure Python parser that turns simple tag-based markup, especially LLM output, into Python dictionaries without any risky XML features.

What language is gravitasml written in?

Mainly Python. The stack also includes Python, Pydantic.

What license does gravitasml use?

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

How hard is gravitasml to set up?

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

Who is gravitasml for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.