# How to make a named tuple from a dictionary?

**URL:** <https://discourse.julialang.org/t/how-to-make-a-named-tuple-from-a-dictionary/10899>\
**Category:** General Usage\
**Tags:** dictionary, namedtuple\
**Created:** [May 15, 2018, 2:30am UTC](https://discourse.julialang.org/t/how-to-make-a-named-tuple-from-a-dictionary/10899 "2018-05-15T02:30:13Z")\
**Posts on this page:** 1\
**Page:** 3

<div class="post-metadata">

**Author:** ![rocco\_sprmnt21](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rocco_sprmnt21/32/20127_2.png) [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Post date:** [June 23, 2023, 1:04pm UTC](https://discourse.julialang.org/t/how-to-make-a-named-tuple-from-a-dictionary/10899/46 "2023-06-23T13:04:37Z")

</div>

map and collect are also not strictly necessary

```julia
namedtuple(x) = x
namedtuple(d::Dict) = (; (Symbol(k) => namedtuple(v) for (k,v) in d)...)

dind=Dict('A'=>1,'B'=>d,'C'=>3)
julia> namedtuple(dind)
(C = 3, A = 1, B = (c = 7, b = 6, a = 5))

```

[Previous page](https://discourse.julialang.org/t/how-to-make-a-named-tuple-from-a-dictionary/10899.md?page=2)
