Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

110
Vistas
Convert svg image from url to base64 in node

I would like to use svg image that I have from url, convert it to base64. Later on I am posting this image on social media platform. That is why I need it to be in base64 format. How can I achieve that? I know how to do that when I have this picture on my website but how can I do that when I have only a link to that image?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Here is the simple code which can be used in node.js using node-fetch library.

import fetch from 'node-fetch';

const download = async () => {
const response = await fetch("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/410.svg");
if (response.ok) {
    const buffer = await response.buffer();
    const base64 = buffer.toString("base64");
    return base64;
    }
}

(async () => {
const data = await download();
console.log("🚀 ~ file: base64.js ~ line 12 ~ data", data);
})();

I'm using sample svg image from this link. Above code will return you base64 of the sample svg image :

PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj4KICA8cGF0aCBkPSJNMzAsMWg0MGwyOSwyOXY0MGwtMjksMjloLTQwbC0yOS0yOXYtNDB6IiBzdHJva2U9IiMwMDAiIGZpbGw9Im5vbmUiLz4gCiAgPHBhdGggZD0iTTMxLDNoMzhsMjgsMjh2MzhsLTI4LDI4aC0zOGwtMjgtMjh2LTM4eiIgZmlsbD0iI2EyMyIvPiAKICA8dGV4dCB4PSI1MCIgeT0iNjgiIGZvbnQtc2l6ZT0iNDgiIGZpbGw9IiNGRkYiIHRleHQtYW5jaG9yPSJtaWRkbGUiPjwhW0NEQVRBWzQxMF1dPjwvdGV4dD4KPC9zdmc+Cg==

If you copy and paste this here, you will see the preview of the same image. Voila !!

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda