Encoding hash marks (markdown headers) for x-callback

When I try to send text that has a hash mark (#) in it to Day One, the hash mark stops the rest of the text from going through. I need to escape that hash mark to %23.

However, when I use the encodeURI function (MDN documentation), it does not percent encode this character. What can I do to make it return %23 instead of #?


If you are encoding URL query parameters, you want to use encodeURIComponent, not encodeURI. They are similar, but slightly different.