USD to Text
Read your stage as source code
- USD
- usda_text
USD to Text turns any stage into ASCII USDA source code. You feed it a USD stage and it hands you the whole thing as readable text - the prim hierarchy, the attributes, the transforms, the references. It's the pack's inspection tool, the thing you run when you loaded a file and have no idea what's actually in it, and it's the other half of the "live USDA editing" loop that Text to USD closes.
Why you'd reach for it
You can't edit what you can't see, and a USD stage is invisible until you either view it or read it. USD to Text is the read. Three jobs it does well:
- Inspect before you edit. Every Set/Transform node in this pack takes a
prim_path, and they all fail loudly when the path matches nothing. Reading the.usdafirst tells you the actual paths - is it/Root/Meshor/World/Cube? - instead of guessing. This is the node that stops you from typingprim_pathblind. - Round-trip editing. Dump a stage to text, edit the text in any string node (or hand it to an LLM), feed it back through
Text to USD, save. The dedicated nodes cover the common edits; text covers everything else. - Verify the save. Run a stage through USD to Text and you can read exactly what would hit disk before you run
SaveUSD.
How it works
Mechanically it's a single call: stage.GetRootLayer().ExportToString(). No file is written, no network involved - the root layer is serialized to a string in memory and handed out on a normal STRING socket.
One detail shapes everything else: it serializes the root layer, not the flattened stage. If your stage is made of references and sublayers, those show up as their composition arcs - a line like references = @asset.usd@ - not as expanded contents. You get a true picture of the structure, but not of the fully composed result. To see everything baked into one blob, flatten first (SaveUSD with flatten_stage on, or a USD Python Script calling Flatten). Interestingly, the pack's viewer server does flatten in-memory stages before serving them - but this node doesn't. Don't expect the two to agree on composed content.
Inputs and output
USD- the stage to serialize.- Output:
usda_text, a plainSTRING. Wire it into any text display node, aText to USDfor the round-trip, or an LLM node for summarization or code generation.
Install
Standard for the pack - ComfyUI Manager, search "ComfyUI-OpenUSD", or:
cd ComfyUI/custom_nodes
git clone https://github.com/cjhosken/ComfyUI-OpenUSD
Restart. Dependencies: usd-core==26.5 (the big USD bindings, one-time heavy install), numpy, trimesh, pygltflib. No models anywhere in this pack.
Troubleshooting
- The output shows
@file.usd@references instead of content - that's the root-layer-only behavior, not a bug. Flatten first if you want composed text. - It's slower than you'd like on big stages - serializing a large layer to a string isn't free, but it's still the cheapest inspection tool in the pack.
- You expected the exact bytes of the original file - you'll get a re-serialized layer, which is semantically identical but not byte-identical to what a DCC wrote. That's normal USD behavior, not corruption.
Pack-level honesty, same as the rest: v0.1.1, brand new, no community track record. This is one of the simplest nodes in the pack and one of the most useful - a boring tool that quietly unblocks everything else. Pair it with Text to USD and you've got the pack's whole text-editing story in two nodes.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| USD | USD | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| usda_text | STRING | — |