Free KT test files and sample generator
JetBrains' Kotlin language, the default for Android. Generate valid .kt source files to test uploads, editors, linters and Gradle builds.
What is a .kt file?
KT: Kotlin Source. Kotlin source is plain text, so the interesting part for testing is not the bytes but the size and the surroundings: how your tooling handles a file of this type at a given size, with a given encoding, or when it is truncated mid-token.
Why generate a test KT file?
- Check that an upload form, code viewer or diff tool accepts a .kt file and renders it correctly.
- Exercise size limits in CI artifacts, linters and static-analysis steps without waiting on a real repository.
- Feed a truncated or corrupted copy to a parser to confirm it fails cleanly instead of hanging.
What you can put inside a .kt file
You get 3 content options for KT, so the file holds something meaningful rather than random padding: Definitions, Simple statements, With comments. For KT these are alternatives, so choose the one that matches what you need to test.
How a .kt file is identified
A .kt file has no signature at the start. A text format has no identifying leading bytes, so the extension and the reported media type are the only claims about it until a parser actually reads it, which is why validating uploads by extension alone is unsafe.
How the size lands on the exact byte
The format allows comments, so the padding is comment lines, legal, inert, and visible if you open the file.
Negative testing with broken KT files
- Invalid. Identifiable, but wrong inside, so it fails during parsing.
- Corrupted. The leading bytes are destroyed. 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, and for this format's encodings, UTF-16 and BOM test files.
Sample KT content
fun test0(): Int = 137 fun test1(): Int = 274
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
Open in IntelliJ IDEA or Android Studio, or compile with `kotlinc`.
Media type text/x-kotlin · extension .kt · category Code
Generate a .kt file → · questions about sizes, privacy or cost are answered on the site FAQ.
Frequently asked questions about KT files
What identifies a .kt file?
Nothing at the start of the file does. A text format has no identifying leading bytes, so the extension and the reported media type are the only claims about it until a parser actually reads it, which is why validating uploads by extension alone is unsafe.
How can a .kt file be an exact number of bytes?
The format allows comments, so the padding is comment lines, legal, inert, and visible if you open the file.
What can go inside the KT file?
There are 3 content options for .kt: Definitions, Simple statements, With comments. For KT these are alternatives, so pick the one matching what you need to test.
Can I download several broken KT files at once?
Yes, select more than one File Condition and you get one ZIP containing a .kt per condition, each named after its condition.
Can the KT file use UTF-16 or a byte-order mark?
Yes. .kt is a text format, so it can be generated as UTF-8, UTF-8 with a byte-order mark, UTF-16 LE or UTF-16 BE. The body is shortened before re-encoding so the finished file still lands on the exact size you asked for. Note that a UTF-16 file always has an even byte count.
How do I open or verify the KT file?
Open in IntelliJ IDEA or Android Studio, or compile with kotlinc.