VOOZH about

URL: https://www.geeksforgeeks.org/node-js/node-js-zlib-gzipsync-method/

⇱ Node.js zlib.gzipSync() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Node.js zlib.gzipSync() Method

Last Updated : 28 Apr, 2025

The zlib.gzipSync() method is an inbuilt application programming interface of the Zlib module which is used to compress a chunk of data with Gzip. 

Syntax:

zlib.gzipSync( buffer, options )

Parameters: This method accepts two parameters as mentioned above and described below:

  • buffer: This parameter holds the buffer of type Buffer, TypedArray, DataView, ArrayBuffer, and string.
  • options: This parameter holds the value of the zlib option.

Return Value: It returns the chunk of data with Gzip. 

The below examples illustrate the use of zlib.gzipSync() method in Node.js: 

Example 1: 

Output:

<Buffer 1f 8b 08 00 00 00 00 00 00 03 f3 cb
 4c c9 c8 04 00 13 f2 5b b1 05 00 00 00>

Example 2: 

Output:

1f8b0800000000000003f3cb4cc9c8040013f25bb105000000

Reference: https://nodejs.org/api/zlib.html#zlib_zlib_gzipsync_buffer_options

Comment

Explore