Well Nim is a statically typed language safety in mind so its not really designed to do what you request.
If you know what all the possible types are you can use a sequence of object variants. ( This is basically what the JSON library is anyway ) type NodeKind = enum # the different node types nkInt, # a leaf with an integer value nkFloat, # a leaf with a float value nkString # a leaf with a string value Node = ref object case kind: NodeKind # the ``kind`` field is the discriminator of nkInt: intVal: int of nkFloat: floatVal: float of nkString: strVal: string var n = @[ Node(kind: nkFloat, floatVal: 1.0), Node(kind: nkString, strVal: "Simple") ] n.add Node(kind: nkInt, intVal: 3) Run