Human-readable Ruby Marshal alternative. Serialize objects to Markdown with full round-trip fidelity.
gem install marshal-md
\x04\b{\a:\tname\"\nAlice:\bage\x1Ei\x23
{name: "Alice", age: 30} (Hash)
require "marshal-md"
md = MarshalMd.dump(obj) # Ruby object -> Markdown string
obj = MarshalMd.load(md) # Markdown string -> Ruby object
MarshalMd.dump(obj, io) # write to IO
MarshalMd.dump(obj, 3) # depth limit
MarshalMd.load(md, proc) # proc callback
MarshalMd.load(md, freeze: true) # freeze all objects
# Drop-in replacement
require "marshal-md/patch"
Marshal.dump(obj) # now outputs Markdown
Marshal.load(md) # auto-detects format
Integer, Float, String, Symbol, Array, Hash, Range, Regexp, Time, Struct, Complex, Rational, Encoding, Exception, Class, Module, and any custom object.
Anchor/reference syntax handles shared objects and circular references, just like Marshal.
Pure Ruby. No external gems. Works with Ruby 2.5+.
MyArray < Array, MyTime < Time, etc. Preserves class identity, instance variables, and module extensions.
Depth limit, IO/pipe, proc callback, freeze mode, compare_by_identity, safety checks for recursive dump and mutation detection.
Scalars have no type annotations. Text output works with git diff, code review, and version control.
# Scalars — no type annotations needed
42
"hello"
:foo
true
# Nested objects
#<User> (User)
@name: "Alice"
@scores: [85, 92, 78] (Array)
@address:
#<Address> (Address)
@city: "Tokyo"
@zip: "100-0001"
# Circular reference
&obj_1 (Array)
1
2
*obj_1 (ref)
# Binary data
base64:iVBORw0KGgo... (String, ASCII-8BIT, 4096 bytes)