Free PKG test files and sample generator
The macOS flat installer package, a xar archive holding a Distribution description, a PackageInfo manifest and a payload. Generate valid .pkg sample files to test archive tooling, scanners and upload handling.
What is a .pkg file?
PKG: macOS Installer Package. A macOS installer package is a xar archive: a header, a compressed table of contents, then a heap of file data. The TOC is XML listing every file with its offset and length, which is why readers never have to scan the archive. Inside sit a Distribution script describing the install UI, a PackageInfo manifest and the payload.
Why generate a test PKG file?
- Test a software-distribution or artifact pipeline that handles macOS installers.
- Verify archive detection and scanning of xar-format files.
- Check upload handling and size limits for installer downloads.
How a .pkg file is identified
Every .pkg file begins with 78 61 72 21, "xar!". A macOS installer package is an eXtensible ARchive. That is what a validator inspecting content rather than the file name looks for.
Negative testing with broken PKG files
- Invalid. Identifiable, but wrong inside, so it fails during parsing.
- Corrupted. The leading bytes are destroyed, so the
78 61 72 21identifying a .pkg is gone. Same length as the valid file. - Incomplete. Truncated part-way, so it is genuinely shorter.
- Empty. Chosen under Content rather than File Condition: valid structure, no data.
Which failure to reach for, and what to assert for each, is covered in how to make a corrupted file for testing. For upload limits and type checks see testing file upload validation.
Sample PKG content
[PKG], xar container: header + zlib-compressed TOC + heap (Distribution, PackageInfo, Payload).
This shows the shape of the file. Your download is generated fresh at the size you choose, so the values will differ.
How to open and verify the file
List with `xar -tf file.pkg` or expand with `pkgutil --expand file.pkg` on macOS. `tar -tvf file.pkg` works anywhere libarchive is present, including Windows.
Media type application/vnd.apple.installer+xml · extension .pkg · category Scripts & OS
Generate a .pkg file → · questions about sizes, privacy or cost are answered on the site FAQ.
Frequently asked questions about PKG files
What identifies a .pkg file?
A .pkg file begins with the bytes 78 61 72 21, "xar!". A macOS installer package is an eXtensible ARchive. Those bytes are what a content-sniffing validator looks for, and what the Corrupted condition destroys.
Can I download several broken PKG files at once?
Yes, select more than one File Condition and you get one ZIP containing a .pkg per condition, each named after its condition.
Can the PKG file use UTF-16 or a byte-order mark?
No, and deliberately. A .pkg file is a container rather than plain text, so rewriting its bytes as UTF-16 would not produce a UTF-16 document. It would produce a broken file. Use a text format such as CSV, JSON or XML for encoding tests.
How do I open or verify the PKG file?
List with xar -tf file.pkg or expand with pkgutil --expand file.pkg on macOS. tar -tvf file.pkg works anywhere libarchive is present, including Windows.