You can use btoa() and atob() to convert to and from baseencoding. There appears to be some confusion in the comments regarding what . They always get wrong output for non-English characters. The btoa() method of window object is used to convert a given string to a encoded data (using base-encoding) string. Creates encoded data from the given string, using base-encoding.