JavaFX Markdown Preview is a modern and lightweight library designed to render Markdown content seamlessly in JavaFX applications.
Whether you’re building a Markdown editor, a documentation viewer, or just need a clean way to preview .md
content inside your app — this tool saves you hours of work by offering a plug-and-play experience.
✅ Plug-and-play setup – Integrate in just minutes
✅ Live preview support – Automatically updates when the file changes
✅ Cross-platform UI – Works on Windows, macOS, and Linux
✅ Flexmark-powered – Renders CommonMark-compliant Markdown
✅ No browser dependencies – Uses JavaFX WebView internally
✅ Reusable – Add to any JavaFX or plain Java project easily
Whether you're developing documentation tools, note-taking apps, IDE plugins, or just need a Markdown viewer, this tool offers a ready-made and customizable solution.
- 📂 Load
.md
file or raw Markdown string - 🔄 Real-time preview with file change detection
- 🖥️ Opens in a separate JavaFX window
- 🔁 Reopen preview window if closed
- ☕ Supports both Java and JavaFX projects
- ⚡ Lightweight and reusable as a utility
Add the dependency in your pom.xml
:
<dependency>
<groupId>io.github.raghul-tech</groupId>
<artifactId>javafx-markdown-preview</artifactId>
<version>1.0.1</version>
</dependency>
Or browse it on Maven Central.
- Load from Markdown File
import com.raghultech.markdown.preview.JavaFXMarkdownPreview;
import java.io.File;
import java.util.Scanner;
public class Markdown {
public static void main(String[] args) {
File file = new File("demo.md");
JavaFXMarkdownPreview preview = new JavaFXMarkdownPreview(file);
preview.launchPreview();
Scanner scanner = new Scanner(System.in);
while (true) {
while (preview.isPreviewShowing()) {
try { Thread.sleep(1000); } catch (InterruptedException ignored) {}
}
System.out.print("Preview window closed. Reopen? (yes/no): ");
String response = scanner.nextLine().trim().toLowerCase();
if (response.equals("yes")) {
preview.reopenWindow();
} else {
System.out.println("Exiting...");
break;
}
}
scanner.close();
System.exit(0);
}
}
- Load from Markdown String
import com.raghultech.markdown.preview.JavaFXMarkdownPreview;
import java.util.Scanner;
public class Markdown {
public static void main(String[] args) {
String content = "# ☕ JavaFX Markdown Preview\n\n" +
"A simple and elegant **Markdown preview tool** using JavaFX and Flexmark.\n\n" +
"---\n\n" +
"## ✨ Features\n" +
"- 📂 Load `.md` files or string input\n" +
"- 🔄 Real-time file change detection\n" +
"- 🖥️ Separate JavaFX window for previewing\n" +
"- 🔁 Reopen preview window if closed\n";
JavaFXMarkdownPreview preview = new JavaFXMarkdownPreview(content);
preview.launchPreview();
Scanner scanner = new Scanner(System.in);
while (true) {
while (preview.isPreviewShowing()) {
try { Thread.sleep(1000); } catch (InterruptedException ignored) {}
}
System.out.print("Preview window closed. Reopen? (yes/no): ");
String response = scanner.nextLine().trim().toLowerCase();
if (response.equals("yes")) {
preview.reopenWindow();
} else {
System.out.println("Exiting...");
break;
}
}
scanner.close();
System.exit(0);
}
}
javac -cp JavaFX-Markdown-Preview-1.0.1.jar Markdown.java
Windows:
java -cp .;JavaFX-Markdown-Preview-1.0.1.jar Markdown
Linux/macOS:
java -cp .:JavaFX-Markdown-Preview-1.0.1.jar Markdown
-
Java 8 or above
-
JavaFX (use OpenJFX for Java 11+)
-
Maven for dependency management
- View all releases on the Releases Page.
- For a detailed log of all changes, refer to the CHANGELOG.md file.
-
The preview may break briefly when typing fast due to background re-parsing.
-
Workaround: Pause briefly or trigger a manual refresh if needed.
-
Emoji rendering depends on online font support (e.g., via web or CDN).
-
Offline systems may display missing glyphs or boxes.
-
This is a system font limitation, not a library bug.
-
We welcome contributions of all kinds:
-
🛠️ Bug fixes
-
🌟 Feature suggestions
-
📚 Documentation improvements
-
🧪 More usage examples
-
Please check the Contributing Guide before starting.
- If you've encountered a bug, please report it by clicking the link below. This will guide you through the bug-reporting process: ➡️ Click here to report a bug
- This project is licensed under the MIT License.
Email: raghultech.app@gmail.com
If you find this project useful, consider buying me a coffee!