---
schema_version: "1"
id: 36bba826c123d94bacc1b4a8a66dd6ae0f399049077218c16fab49e35dcf2373
title: ZIP Support
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexcode/apex_zip.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_zip.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 90032eb07a2ca38a5d1e57a0074558735cb86426d81c63ddaeded82d084989d3
description: Take advantage of a native Apex Zip library to create and extract ZIP archive files by using the class methods in the Compression namespace.
---
# ZIP Support

Take advantage of a native Apex Zip library to create and extract ZIP archive files by using the class methods in the Compression namespace.

You can compress multiple attachments or documents into an Apex blob that contains the ZIP archive. You can also specify the data to be extracted from the zip archive, without uncompressing the entire ZIP archive. To optimize compression, you can specify a compression method and compression level.

This example code extracts a JSON translation file from a callout response containing a ZIP archive by getting and extracting the specified entry from the ZIP archive.

HttpRequest request = new HttpRequest();
request.setEndpoint('callout:My\_Named\_Credential/translationService');
request.setMethod('POST');
// Set request payload to translate...

HttpResponse response = new Http().send(request);
Blob translationZip = response.getBodyAsBlob();

ZipReader reader = new ZipReader(translationZip);
ZipEntry frTranslation = reader.getEntry('translations/fr.json');
Blob frTranslationData = reader.extractEntry(frTranslation);

#### See Also

- [_Apex Reference Guide_: Compression NameSpace](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexref.meta/apexref/apex_namespace_Compression.htm "Apex Reference Guide: Compression NameSpace - HTML (New Window)")