You can use JSZIP.

**use npm to install JSZIP

let zip = require('jszip')();
//hoping you have already taken input
let input = document.getElementById('fileInput'); // fileInput is id of my input element
let file = input.files[0];
let allZip =  zip.file(file.name, file);
console.log(allZip)
Answer from Ashish Yadav on Stack Overflow
🌐
Medium
medium.com › @kuldeepkrsharma00 › how-to-zip-a-file-and-upload-using-react-a-step-by-step-guide-2f3cf18f5b41
How to Zip a File and upload using React: A Step-by-Step Guide | by Kuldeepkrsharma | Medium
January 25, 2024 - These functions are designed to be used in the context of handling selected files, creating previews, formatting sizes, and managing state in a React application. In summary, the formatBytes function takes a size in bytes, converts it to the appropriate size unit (KB, MB, etc.), rounds it to the specified number of decimal places, and returns a formatted string representing the size. It is a utility function often used in file handling scenarios to present file sizes in a human-readable format. Finally, it calls the handleZipFiles function, to zip then upload the selected files.
Discussions

How to Extract and Use a ZIP File from the assets/ Folder in a React Native Project?
Forget the zip part. The bundle is compressed anyway. JSON files can be directly imported but that will include them in the bundle and hence in memory which I doubt you want. You need expo-fs to open files bundled as assets. https://docs.expo.dev/versions/latest/sdk/filesystem/ https://docs.expo.dev/develop/user-interface/assets/ Re-word what I said as a question and ChatGPT will answer you with the code. Probably with some mistakes but that's part of the fun of using it. More on reddit.com
🌐 r/reactnative
4
1
December 19, 2024
How to read the zip file contents in react application using jszip preferably
1 When trying to read a file in react application with webpack Uncaught TypeError: fs__WEBPACK_IMPORTED_MODULE_16___default.a.readFile is not a function · 22 Extracting zipped files using JSZIP in javascript More on stackoverflow.com
🌐 stackoverflow.com
Download a zip file in reactjs without any plugins - Stack Overflow
But the downloaded gz file was not able to open (seems to be corrupted). can some one help me with downloading zip file in reactjs. More on stackoverflow.com
🌐 stackoverflow.com
reactjs - Download and zip files in React? - Stack Overflow
I have an application that stores consultations for users. The consultation has data about the user and has documents attached to the consultation. My goal is to return all documents that were atta... More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
github.com › Ishaan28malik › react-zip-download
GitHub - Ishaan28malik/react-zip-download: A project to implement multi file zip downloader using Reactjs · GitHub
A project to implement multi file zip downloader using Reactjs - Ishaan28malik/react-zip-download
Starred by 6 users
Forked by 5 users
Languages   HTML 64.0% | CSS 26.7% | JavaScript 9.3%
🌐
npm
npmjs.com › package › react-native-zip-archive
react-native-zip-archive - npm
Latest version: 7.0.2, last published: 9 months ago. Start using react-native-zip-archive in your project by running `npm i react-native-zip-archive`. There are 31 other projects in the npm registry using react-native-zip-archive.
      » npm install react-native-zip-archive
    
Published   Jun 15, 2025
Version   7.0.2
Author   Perry Poon
🌐
DEV Community
dev.to › jaydeepkhachariya › how-make-zip-of-images-and-download-it-using-react-js-in-3-easy-steps-lkb
How make zip of images and download it using React JS in 3 Easy steps - DEV Community
January 27, 2023 - import { useState, useCallback } from "react"; import JSZip from "jszip"; export default Download(){ const [images,setImages]=useState([ // Array of images "image1.jpg", "image2.jpg", "image3.jpg", "image4.jpg", "image5.jpg", ]) const zip = new JSZip(); // instance of JSZip // Function for make zip file and download it async function handleZip(){ // Add Images to the zip file for (var i = 0; i < images.length; i++) { const response = await fetch(images[i]); const blob = await response.blob(); console.log(blob); zip.file(images[i].split("/").pop(), blob); if (i == selectedImages.length - 1) { /
🌐
GitHub
github.com › adamsoutar › covalent-zip
GitHub - adamsoutar/covalent-zip: A React.js zip file client for the web
Create, compress, and download newly created zip files, explore, preview and download files from existing zip files (without downloading the whole thing), and restructure/upload files to existing zip files before re-compressing and downloading them... all in the browser, and all client side with a React frontend!
Author   adamsoutar
🌐
StackBlitz
stackblitz.com › edit › zip-file-downloader-react
Zip File Downloader React - StackBlitz
Starter project for React apps that exports to the create-react-app CLI.
Find elsewhere
🌐
Medium
yashodgayashan.medium.com › zip-files-in-react-30fb77fd6a58
Zip files in React. In this tutorial we will go through how… | by Yashod Perera | Medium
November 3, 2020 - <input multiple type="file" name="file" onChange={this.onChangeFile}/> Then let’s implement the onChangeFile method to zip the inputed files.
🌐
Filestack
blog.filestack.com › home › generate a zip file with javascript & react – filestack
Generate a Zip File With Javascript & React - Filestack
April 12, 2019 - The pictures uploaded in the sample app can be downloaded as well. To do so we used the zip process API of Filestack. ... Implementing this in React is very simple to achieve.
🌐
GitHub
github.com › mockingbot › react-native-zip-archive
GitHub - mockingbot/react-native-zip-archive: Zip archive utility for react-native
Zip archive utility for react-native. Contribute to mockingbot/react-native-zip-archive development by creating an account on GitHub.
Starred by 466 users
Forked by 166 users
Languages   Java 64.2% | Objective-C 26.7% | JavaScript 6.7% | Ruby 2.4% | Java 64.2% | Objective-C 26.7% | JavaScript 6.7% | Ruby 2.4%
🌐
Mridul
mridul.tech › home › blogs › how to generate zip with file links in next js and react js
How to Generate ZIP with File Links in Next JS and React JS
December 2, 2023 - Also Read: 10 React Project Ideas to Boost Your Portfolio · 5. Now let’s fetch the file URLs and get the files. We will map over the array and fetch each file from the object. And we can also name the files different name as well. // /pages/index.js import JSZip from "jszip"; const zip = new JSZip(); const remoteZips = files.map(async (file) => { const response = await fetch(file.url); const data = await response.blob(); zip.file(`${file.name}.${file.type}`, data); return data; });
🌐
GitHub
github.com › agarrec-vivlio › react-native-zip-stream
GitHub - alexandre-garrec/react-native-zip-stream: React Native module for streaming files from ZIP archives. · GitHub
A React Native module for working with ZIP archives. This module allows you to list the contents of ZIP files, stream files from ZIP archives, create new ZIP files.
Author   alexandre-garrec
🌐
Reddit
reddit.com › r/reactnative › how to extract and use a zip file from the assets/ folder in a react native project?
r/reactnative on Reddit: How to Extract and Use a ZIP File from the assets/ Folder in a React Native Project?
December 19, 2024 -

How can I extract a files.zip located inside the assets/ folder of a React Native project during app initialization and import the contained .json files?

I have a files.zip file in the assets/ folder, which contains .json data to be used in my app. I want to extract this zip file and import the .json files when the app starts. Here’s what I’ve tried so far:

  1. Using react-native-zip-archive: I attempted this, but encountered errors, likely due to version conflicts on iOS.

  2. Using expo-file-system and jszip: Unfortunately, I wasn’t familiar enough with expo-file-system to make it work.

  3. Using require to load the zip file: When I logged the output of requiring the zip file, I only got the number 40. It seems like the zip file isn’t being loaded properly.

Is it not possible to load a zip file directly this way? Are there any alternative approaches to solve this issue?

Here’s my project setup:

  • "expo": "~52.0.7"

  • "react-native": "0.76.5

I started this project using the Ignite boilerplate.

Any advice would be greatly appreciated!

react-native-zip-archive error
🌐
Stack Overflow
stackoverflow.com › questions › 60621829 › how-to-read-the-zip-file-contents-in-react-application-using-jszip-preferably
How to read the zip file contents in react application using jszip preferably
Basically requirement is when user clicks on "maifest" link a pop up needs to shown which show manifest.json contents in the UI react components. I tried using JSZip library, and the code is as below · var zip = new JSZip(); zip.loadAsync("Manifest.zip") .then(function (zip) { console.log(zip.files); // Expected outline.png, publish.png, manifest.json });
🌐
Medium
medium.com › @farihashahid9415 › chunked-and-streamed-file-zipping-in-react-f8d13e465f35
Chunked and Streamed File Zipping in React | by Farihashahid | Medium
November 7, 2025 - ZipWriter: Provided by zip.js, receives streaming data and writes compressed chunks directly into the ZIP file. UI State Manager (React): Maintains live progress, handles user actions (pause/resume/cancel), and reports file-level status.
🌐
Stuk
stuk.github.io › jszip
JSZip
JSZip is a javascript library for creating, reading and editing .zip files, with a lovely and simple API.
Top answer
1 of 1
6

figured I would share my solution, as i've seen alot of questions about this, but not many helpful answers.

using JSZip: https://stuk.github.io/jszip/

using saveAs from fileSaver.js: https://github.com/eligrey/FileSaver.js

First: it loops through downloading each file individually from s3, creates a blob, and puts each blob/file into a "folder".

Second: after each file has been downloaded from s3, it will then use the saveAs method to download/save the zipped folder.

function NewEditInfo(props) {
const [job, setJob] = useState([]);
const [imagesUploaded, setImagesUploaded] = useState(null); 

//initialize jsZip
var JSZip = require("jszip");
let zip = new JSZip();
let photoZip = zip.folder(`${job.streetAddress}`);

useEffect(() => { 
     //// API call to load job info from dynamo db
  function loadJob() {
    return API.get("api name", "/tablename/tableinfo", {
  'queryStringParameters': {jobId: props.match.params.id}    
   }); 
  } 
   /// onload function to load job info and get a count of files
    async function onLoad() {   

      try {
        const job = await loadJob();
        setJob(job[0])

        const ImagesUploaded = await Storage.list(`${job[0].jobId}`);
        setImagesUploaded(ImagesUploaded);

        } catch (e) {
          alert(e);
      }

    }

    onLoad();
  }, [props.match.params.id,]);


  /// On download button click, loop through / download images using the key given from storage.list in onload function
  async function handleDownloadClick(event) {
         event.preventDefault();    
      const imagesAsArray = [...imagesUploaded];

    for (let i = 0; i < imagesAsArray.length; i++) {                                                                                          
      await DownloadFileFromS3(imagesAsArray[i]); 
        }
       /// waits for "await DownloadFileFromS3, then executes the save as which saves the zipped folder created in "DownloadFileFromS3"
        zip.generateAsync({type:"blob"})
             .then(function(content) {
        saveAs(content, `${job.streetAddress}`);
        });
   }


    /// download each file from s3 and put it in the zip folder
    async function DownloadFileFromS3(fileToDownload) {

        const result = await Storage.get(fileToDownload.key, {download: true})

        let mimeType = result.ContentType
        let fileName = fileToDownload.key
        let blob = new Blob([result.Body], {type: mimeType})

        photoZip.file(fileName[1], blob)

   }

 return(

      <IonPage>
      <IonHeader>
        <IonToolbar>
      <IonButtons slot="start">
          <IonBackButton/>
      </IonButtons>
          <IonTitle>Download Images</IonTitle>
        </IonToolbar>
      </IonHeader>  
      <IonContent className="ion-padding">   
      <IonButton onclick={handleDownloadClick}> download </IonButton>
      </IonContent>
      </IonPage>
    );


  }


export default withRouter(NewEditInfo);
🌐
Reddit
reddit.com › r/javascript › generate a zip file programmatically with javascript & react
r/javascript on Reddit: Generate a Zip File Programmatically with Javascript & React
September 19, 2015 - When I need to create a zip I have leaked instructions to a node child process for the OS's native zip utility to create/unzip the zip file.