# Create unit from string with Unitful.jl

**URL:** <https://discourse.julialang.org/t/create-unit-from-string-with-unitful-jl/33666>\
**Category:** Data\
**Tags:** unitful\
**Created:** [January 22, 2020, 3:35pm UTC](https://discourse.julialang.org/t/create-unit-from-string-with-unitful-jl/33666 "2020-01-22T15:35:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![moesphere](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/moesphere/32/3348_2.png) [@moesphere](https://discourse.julialang.org/u/moesphere)\
**Post date:** [January 22, 2020, 3:35pm UTC](https://discourse.julialang.org/t/create-unit-from-string-with-unitful-jl/33666/1 "2020-01-22T15:35:50Z")

</div>

Is it possible to create a unit from a string with the Unitful.jl package at runtime without using `eval`?

Something like this:

```julia
unit_str = "mol/L"
unitful_unit = unit(unit_str)

```

I only found `u"..."` and `@u_str`, where string interpolation is not possible imho.

Edit: In the case of standalone units, it is possible to do this:

```julia
unit_str = "m"
getfield(Unitful, Symbol(unit_str))

```

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [January 22, 2020, 4:13pm UTC](https://discourse.julialang.org/t/create-unit-from-string-with-unitful-jl/33666/2 "2020-01-22T16:13:18Z")

</div>

You may be interested in following [Parsing of units from strings by c42f · Pull Request #298 · PainterQubits/Unitful.jl · GitHub](https://github.com/PainterQubits/Unitful.jl/pull/298)
