Python3 oneliner: <!-- language: shell --> python3 -c "import zlib,sys; sys.stdout.buffer.write(zlib.decompress(sys.stdin.buffer.read()))" < infile > outfile This way the contents is handled as binary data, avoiding conversion to/from unicode.