how can I change color of an svg img in base64 format?

For a simple unicolor base64 encoded SVG, you can tweak the color via CSS filters.

The filters you need to apply vary. As your base64 encoded SVG is in black unicolor you first invert it to white. Then apply sepia and saturate it properly. Lastly, you tweak the yellow tone you now have via hue-rotate to your desired color.

img {
  filter: invert(1) sepia(100%) saturate(10000%) hue-rotate(45deg);
}

As you do not clarified if can't modify the original file or if must do it on client-side, I propose a

Programmatically approach:

  1. Lookup the <img>
  2. From img.src strip "data:image...", to extract Base64 encoded SVG.
  3. Decode it using atob
  4. Create an element, just for find the <path>
  5. Set fill on path.
  6. Append the new Image or Replace current one.

Example:

// Lookup the <img> by Id
var img = document.getElementById("target");

// Strip "data:image/svg+xml;base64," to get encoded SVG
var encoded = img.src.substring(26);

// Decode base64
var decoded = atob(encoded);

// Create an HTML element from decoded SVG
var wrapper = document.createElement('div');
wrapper.innerHTML = decoded;
var newSvg = wrapper.firstChild;

// Lookup the <path> and get a ref
var innerPath = newSvg.getElementsByTagName('path')[0];

// Set up new color
innerPath.setAttribute("fill", "#FF0000");

// Show modified image
document.body.appendChild(newSvg);
<img id="target" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iNS4wIC0xMC4wIDEwMC4wIDEzNS4wIiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCAxMDAgMTAwIiB4bWw6c3BhY2U9InByZXNlcnZlIiBoZWlnaHQ9IjEwMHB4IiB3aWR0aD0iMTAwcHgiPgo8cGF0aCBpZD0icGF0aDE5ODNfM18iIGQ9Ik01MC4xLDQuOXY3LjRjMCwwLDAsMC0wLjIsMGMtMC4xLDAtMC40LDAuMi0wLjQsMC40YzAsMC4yLDAsNS4xLDAsNS4zYzAsMC4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4zLTMuNmMwLDAsMC0xLjUsMC0xLjdjMC0wLjItMC4yLTAuMi0wLjItMC40czAtNC42LDAtNC44YzAtMC4yLTAuMi0wLjItMC4yLTAuNCAgYzAtMC4yLDAtNS4xLDAtNS4zYzAtMC4yLTAuMi0wLjQtMC40LTAuNHMtMC4yLDAtMC4yLDBWNC45aC0wLjRoLTAuMUg1MC4xeiIvPgo8dGV4dCB4PSIwLjAiIHk9IjExNy41IiBmb250LXNpemU9IjUuMCIgZm9udC13ZWlnaHQ9ImJvbGQiIGZvbnQtZmFtaWx5PSJIZWx2ZXRpY2EgTmV1ZSwgSGVsdmV0aWNhLCBBcmlhbC1Vbmljb2RlLCBBcmlhbCwgU2Fucy1zZXJpZiIgZmlsbD0iIzAwMDAwMCI+Q3JlYXRlZCBieSBMYXphciBOaWtvbGljPC90ZXh0Pjx0ZXh0IHg9IjAuMCIgeT0iMTIyLjUiIGZvbnQtc2l6ZT0iNS4wIiBmb250LXdlaWdodD0iYm9sZCIgZm9udC1mYW1pbHk9IkhlbHZldGljYSBOZXVlLCBIZWx2ZXRpY2EsIEFyaWFsLVVuaWNvZGUsIEFyaWFsLCBTYW5zLXNlcmlmIiBmaWxsPSIjMDAwMDAwIj5mcm9tIHRoZSBOb3VuIFByb2plY3Q8L3RleHQ+PC9zdmc+">

Note:

There are some restrictions on IE < 10

Can I use atob?

EDIT: Muplipath Approach

var paths = newSvg.getElementsByTagName('path');
[].forEach.call(paths, function(path) {
    path.setAttribute("fill", "#FF0000");
});

This worked for me with the help of https://base64.guru:

  1. Use https://base64.guru/converter/decode/image/svg to convert the base64 code to an SVG, download that SVG, edit it as necessary
  2. Use https://base64.guru/converter/encode/image/svg to convert your edited SVG back to base64 and copy the resulting code

Fantastic free site, saved a lot of time for me.