Pages

Tuesday, 3 December 2024

OPML to JSON Converter Tool



OPML to JSON Converter

OPML to JSON Converter

Upload an OPML file and convert it to JSON format.

Converted JSON

Created by Your Name

* { box-sizing: border-box; margin: 0; padding: 0; } body { font-family: Arial, sans-serif; background-color: #f8f9fa; color: #333; display: flex; justify-content: center; align-items: center; min-height: 100vh; margin: 0; } .container { background-color: #ffffff; border-radius: 8px; padding: 30px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); width: 90%; max-width: 800px; } h1 { text-align: center; color: #007bff; margin-bottom: 20px; } .upload-section { display: flex; flex-direction: column; align-items: center; margin-bottom: 20px; } .upload-section input { margin-bottom: 15px; padding: 10px; font-size: 16px; border: 1px solid #ccc; border-radius: 5px; width: 100%; max-width: 300px; } .upload-section button { background-color: #007bff; color: white; border: none; padding: 10px 20px; border-radius: 5px; cursor: pointer; transition: background-color 0.3s; } .upload-section button:hover { background-color: #0056b3; } .output-section { margin-top: 30px; } textarea { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 5px; font-family: 'Courier New', Courier, monospace; font-size: 14px; color: #333; resize: vertical; background-color: #f1f1f1; } footer { text-align: center; margin-top: 30px; font-size: 14px; color: #777; } @media (max-width: 600px) { .container { padding: 20px; width: 100%; } h1 { font-size: 24px; } textarea { font-size: 12px; } } // Function to handle the OPML file input and convert it to JSON function convertToJSON() { const fileInput = document.getElementById('opml-file'); const outputArea = document.getElementById('json-output'); const file = fileInput.files[0]; if (!file) { alert("Please select an OPML file."); return; } const reader = new FileReader(); reader.onload = function(event) { const opmlData = event.target.result; try { // Parse the OPML content using the OPML library const opml = OPML.parse(opmlData); // Convert OPML to JSON and display it in the textarea outputArea.value = JSON.stringify(opml, null, 2); } catch (error) { outputArea.value = `Error parsing OPML: ${error.message}`; } }; reader.readAsText(file); }