Create a JSON File Compressor Web App Using FileSaver.js Library in JS Complete Project For learner

Welcome Learner today in this blog post we will be building a JSON file compressor web app in JS. All the Complete source code of the application is shown Down.


lets Started


In sequence to get begun, you require to make an index.html file and copy-paste the following code.





<h1>JSON Compressor</h1>
<input type="file" accept=".json" />

<script src=""></script>






document.querySelector("input").onchange = function(evt) {
    try {
        var f =[0];
        var r = new FileReader();
        r.onload = function(e) {
            try {
                var contents =;
                var name =;
                saveAs(new Blob([JSON.stringify(JSON.parse(contents))], {
                    type: 'application/json'
                }), name);
            } catch (e) {
                document.querySelector("pre").textContent = e.stack;
    } catch (e) {
        document.querySelector("pre").textContent = e.stack;

Leave a Comment

Your email address will not be published. Required fields are marked *