Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

195
Views
convert base64 string to base64 url in node.js

I was wonder how to convert a base64 string to a base 64 url that you could use in the browser for my project. I've already tried using base64.toString('base64url'), but that didn't work. Below is some example code.

const fs=require("fs")

let base64image=fs.readFileSync("./image.png").toString("base64")
let base64txt=fs.readFileSync("./text.txt").toString("base64")

// converts base64 to a base 64 URL.
function toBase64URL(filetype, base64){ /* ... */ }

console.log(toBase64URL('png', base64image)) // => data:image/png;base64,iVBORw0KGgoAAAANSUhE...
console.log(toBase64URL('txt', base64txt)) // => data:text/plain;base64,dmVyeSBkZXRhaWxlZCA6KQ==
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!