Awesome Open Source
Awesome Open Source


Test Matrix GitHub release (latest by date) Minimum supported Nim version License buy me a coffee

Serialize native Nim types to strings, streams, or sockets.


There are two operations: freeze and thaw.

freeze[T](input: T; output: Socket or Stream or var string)

import frosty

  data = someArbitraryDataFactory()
  handle = openFileStream("somefile", fmWrite)
# write serialized data into the file handle
freeze(data, handle)
close handle

thaw[T](input: Socket or Stream or string; output: var T)

import frosty

  data: SomeArbitraryType
  handle = openFileStream("somefile", fmRead)
# read deserialized data from the file handle
thaw(handle, data)
close handle

freeze[T](input: T): string

thaw[T](input: Socket or Stream or string): T

import frosty

# adhoc serialization and deserialization
var brrr = freeze("my data")
assert thaw[string](brrr) == "my data"


Frosty can handle cyclic data structures, but not memory graphs of extreme size -- you can exhaust the stack because our traversal is implemented via recursion. This will be solved soon.

Benchmark vs. Flatty

The source to the following benchmark is found in the tests directory.

The benchmark compares frosty to for a few static datatypes -- flatty does not work with cast objects yet.



$ nimph clone disruptek/frosty

or if you're still using Nimble like it's 2012,

$ nimble install


  • --define:frostySorted=on to use Miran's sorta B-Trees.
  • --define:frostyNet=off to omit Socket support for platform reasons.
  • --define:frostyDebug=on to emit some debugging output.


The documentation employs Nim's runnableExamples feature to ensure that usage examples are guaranteed to be accurate. The documentation is rebuilt during the CI process and hosted on GitHub.



Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
nim (183
memory (109
binary (96
types (68
streams (53
strings (47
sockets (35
serialize (20
objects (16

Find Open Source By Browsing 7,000 Topics Across 59 Categories