decode base64 svg data to a svg file decode base64 svg data to a svg file linux linux

decode base64 svg data to a svg file


You can copy/paste the string (data:imageetc included) in the url bar of a modern browser; it will decrypt it for you, then you can simply save the page as an svg.


To address the OP question:

How to decode this to a .svg file in linux ?

Since linux has python by default, I suggest to use python script.

Here is a working example:

import base64 #change "YOURFILE" with the name of your original filewith open("YOURFILE", "rb") as f: encoded = f.read()encoded = encoded.replace("data:image/svg+xml;base64,", "")decoded = base64.b64decode(encoded)#change "NEWFILE" with the name that you want to give your new svg with open("NEWFILE.svg", "wb") as f: f.write(decoded)

If you are new to python, simply copy-paste the code above into a file with .py extension, for example aaabbb.py and then execute it like this:

python aaabbb.py