DEV Community

Cover image for How to decode a URI
Rohit Kumawat
Rohit Kumawat

Posted on

2 1

How to decode a URI

I once found myself in a situation where the URI was changing by clicking on a tag and href was adding parameters like name=dev community as a hash to make the page scrollable to a specific section. Basically, it was encoding the URI by adding a hash to it.
Now I need to decode that URI and extract the name from it. I tried several things but I forgot there is a native JavaScript method that decodes encoded URI.

decodeURI:

  • native javascript method
  • decodes encoded URI

Example:

const encodedURI = "https://example.com?name=dev%20community";

const result = decodeURI(encodedURI); 
//https://example.com?name=dev community
Enter fullscreen mode Exit fullscreen mode

Note: There is also a function in Javascript encodeURI() which encodes the URI.


Kudos to undraw for such great illustrations.
Thanks for reading the article. For more tech tweets Twitter.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

The Fastest, Most Accurate API for Voice AI

Ad Image

Power your Conversational AI with the most accurate real-time speech-to-text API. Available in 50 languages and at <1-second latency. Perfect for building seamless and emotionally intelligent voice experiences.

Start building today ๐Ÿ› ๏ธ

๐Ÿ‘‹ Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay