# How to remove invisible characters in JSON

**URL:** <https://discourse.julialang.org/t/how-to-remove-invisible-characters-in-json/25847>\
**Category:** General Usage\
**Created:** [June 29, 2019, 8:30pm UTC](https://discourse.julialang.org/t/how-to-remove-invisible-characters-in-json/25847 "2019-06-29T20:30:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gavinclarke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gavinclarke/32/9847_2.png) [@Gavinclarke](https://discourse.julialang.org/u/Gavinclarke)\
**Post date:** [June 29, 2019, 8:30pm UTC](https://discourse.julialang.org/t/how-to-remove-invisible-characters-in-json/25847/1 "2019-06-29T20:30:12Z")

</div>

I am querying a json which is returned with invisible characters at the beginning specifically 0xef, 0xbb, 0xbf in UTF8, I have tried replacing them in string from with replace with the code:

clean = replace(unclean, “ï”=\>“”)  
clean = replace(clean, “»”=\>“”)  
clean = replace(clean, “¿” =\>“”)

I am wondering what the best way to remove these characters is?

---

<div class="post-metadata">

**Author:** ![bernhard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bernhard/32/2619_2.png) [@bernhard](https://discourse.julialang.org/u/bernhard)\
**Post date:** [July 1, 2019, 6:39am UTC](https://discourse.julialang.org/t/how-to-remove-invisible-characters-in-json/25847/2 "2019-07-01T06:39:36Z")

</div>

> [@Gavinclarke](#):
>
> clean = replace(unclean, “ï”=\>“”)

Your approach should work. Are there any issues?

You can also do

```julia
clean = replace(unclean, Char(0xef)=>"")

```

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [July 1, 2019, 9:57am UTC](https://discourse.julialang.org/t/how-to-remove-invisible-characters-in-json/25847/3 "2019-07-01T09:57:16Z")

</div>

Another possible way is

```julia
julia> unclean = "abc¿def»ghiïjkl"
"abc¿def»ghiïjkl"

julia> clean = filter(!in(('ï', '»', '¿')), unclean)
"abcdefghijkl"

```

Note, I haven’t benchmarked anything.
