Why convert CLASS to TXT?
A .class file is compiled binary bytecode and cannot be read as text without processing. Developers disassemble or decompile to .txt to inspect what a class does when the original .java source is unavailable, to diff two compiled versions, or to document a library's public API.
How to convert CLASS to TXT
javap (JDK) FREE
Run javap -c -p MyClass in a terminal to print bytecode instructions, then redirect to a file with > MyClass.txt. Add -verbose for constant pool and class version details.
JD-GUI OPEN-SOURCE
Drag the .class file onto JD-GUI and the reconstructed Java source appears in the editor. Use File > Save All Sources to export as a .java file (plain text) and rename to .txt if needed.
CFR OPEN-SOURCE
Run java -jar cfr.jar MyClass.class > MyClass.txt to redirect reconstructed Java source directly to a text file.
About these formats
A CLASS file is compiled Java bytecode - the output javac produces from a .java source file. To run it you need Java (a JDK) installed, then use the command "java MyClass". To read what the…
Open .CLASS details →A TXT file is plain, unformatted text - the simplest document format on any computer. Double-click it: Windows opens it in Notepad, macOS in TextEdit, Linux in gedit. Nothing to install. If…
Open .TXT details →Quality & what to watch
- A
.classfile starts with the magic bytes0xCAFEBABE- opening it in a text editor shows binary garbage, not readable content. javapoutput is bytecode mnemonics (invokevirtual,aload, etc.), not Java source; use JD-GUI or CFR if you need source-like output.- Add
-verbosetojavapto include the class file major version, constant pool, and attribute tables in the output.
Frequently asked questions
What is the difference between javap output and decompiler output?
javap shows bytecode instructions (mnemonics); JD-GUI and CFR reconstruct Java source syntax - both produce plain text but differ significantly in readability.Do I need to install anything extra to use javap?
javap ships with every JDK installation; if you have Java development tools installed, it is already available.Can I convert a .class file to .txt without installing Java?
javap, JD-GUI, and CFR all require Java to run, so a JDK or JRE installation is necessary.