{"id":8311099,"date":"2025-09-18T10:29:44","date_gmt":"2025-09-18T07:29:44","guid":{"rendered":"https:\/\/elementor.com\/tools\/?p=8311099"},"modified":"2025-09-18T10:35:33","modified_gmt":"2025-09-18T07:35:33","slug":"currency-converter","status":"publish","type":"post","link":"https:\/\/elementor.com\/tools\/currency-converter\/","title":{"rendered":"Currency Converter"},"content":{"rendered":"\t\t<div data-elementor-type=\"container\" data-elementor-id=\"8311097\" class=\"elementor elementor-8311097\" data-elementor-post-type=\"elementor_library\">\n\t\t\t\t<div class=\"elementor-element elementor-element-23691a2c e-flex e-con-boxed e-con e-parent\" data-id=\"23691a2c\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-37c3711c elementor-widget elementor-widget-html\" data-id=\"37c3711c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<style>\r\n    \/* --- Styles adapted from your provided code --- *\/\r\n    .html-viewer-app {\r\n        width: 100%;\r\n        max-width: 1280px;\r\n        margin: 0 auto;\r\n        padding: 60px 0 0;\r\n        font-family: 'DM Sans', sans-serif;\r\n        color: #333;\r\n    }\r\n\r\n    .main-content {\r\n        display: flex;\r\n        justify-content: center; \/* Center the single converter box *\/\r\n        align-items: flex-start;\r\n    }\r\n\r\n    \/* Used as the main container\/card for the converter *\/\r\n    .converter-container {\r\n        width: 100%;\r\n        max-width: 550px; \/* A suitable width for a single-panel tool *\/\r\n        background: white;\r\n        border-radius: 8px;\r\n        overflow: hidden;\r\n        box-shadow: 0 4px 15px rgba(0,0,0,0.1);\r\n        border: 1.5px solid #EBEBEB;\r\n    }\r\n\r\n    .section-header {\r\n        background-color: #05047E;\r\n        color: white;\r\n        padding: 16px 24px;\r\n        font-weight: 500;\r\n        font-size: 1.25rem;\r\n    }\r\n    \r\n    .converter-body {\r\n        padding: 24px;\r\n        display: flex;\r\n        flex-direction: column;\r\n        gap: 20px;\r\n    }\r\n    \r\n    .form-group {\r\n        display: flex;\r\n        flex-direction: column;\r\n        gap: 8px;\r\n    }\r\n\r\n    .form-group label {\r\n        font-weight: 500;\r\n        font-size: 0.9rem;\r\n        color: #555;\r\n    }\r\n\r\n    .currency-input, .currency-select {\r\n        width: 100%;\r\n        border: 1.5px solid #EBEBEB;\r\n        outline: none;\r\n        padding: 12px 15px;\r\n        font-family: 'Courier New', monospace;\r\n        font-size: 1rem;\r\n        background-color: #ffffff;\r\n        border-radius: 4px;\r\n        transition: border-color 0.2s, box-shadow 0.2s;\r\n    }\r\n\r\n    .currency-input:focus, .currency-select:focus {\r\n        border-color: #05047E;\r\n        box-shadow: 0 0 0 2px rgba(5, 4, 126, 0.2);\r\n    }\r\n    \r\n    .converter-controls {\r\n        display: flex;\r\n        align-items: center;\r\n        gap: 15px;\r\n    }\r\n\r\n    .converter-controls .form-group {\r\n        flex: 1; \/* Make from\/to groups take equal space *\/\r\n    }\r\n    \r\n    .swap-btn {\r\n        background-color: rgb(255, 255, 255);\r\n        color: black;\r\n        border: 1px solid #ddd;\r\n        border-radius: 50%;\r\n        cursor: pointer;\r\n        font-size: 18px;\r\n        display: flex;\r\n        align-items: center;\r\n        justify-content: center;\r\n        width: 44px;\r\n        height: 44px;\r\n        margin-top: 24px; \/* Align with inputs *\/\r\n        transition: background-color 0.2s, transform 0.2s;\r\n        box-shadow: 0 0 10px rgba(0,0,0,0.05);\r\n    }\r\n\r\n    .swap-btn:hover {\r\n        background-color: #f6f6f6;\r\n        transform: rotate(180deg);\r\n    }\r\n\r\n    .result-display {\r\n        margin-top: 10px;\r\n        padding: 20px;\r\n        background-color: #f7f7f9;\r\n        border: 1.5px solid #EBEBEB;\r\n        border-radius: 4px;\r\n        text-align: center;\r\n        font-size: 1.2rem;\r\n        font-weight: 500;\r\n        min-height: 68px;\r\n        display: flex;\r\n        align-items: center;\r\n        justify-content: center;\r\n    }\r\n\r\n    .result-display .rate {\r\n        font-size: 0.9rem;\r\n        color: #6c757d;\r\n        display: block;\r\n        margin-top: 5px;\r\n        font-weight: 400;\r\n    }\r\n    \r\n    \/* Reusing your button style for the main action *\/\r\n    .format-btn {\r\n        background-color: #000;\r\n        color: white;\r\n        border: none;\r\n        padding: 14px 20px;\r\n        cursor: pointer;\r\n        font-size: 1.125rem;\r\n        font-weight: 500;\r\n        transition: all 0.2s;\r\n        width: 100%;\r\n        border-radius: 4px;\r\n        margin-top: 10px;\r\n    }\r\n\r\n    .format-btn:is(:hover, :focus, :focus-visible, :active){\r\n        background-color: #545454;\r\n    }\r\n\r\n    \/* Media query for smaller screens *\/\r\n    @media (max-width: 768px) {\r\n        .html-viewer-app {\r\n            padding: 20px 0 0;\r\n        }\r\n\r\n        .converter-controls {\r\n            flex-direction: column;\r\n            gap: 10px;\r\n            align-items: stretch;\r\n        }\r\n\r\n        .swap-btn {\r\n            margin: 5px auto;\r\n            transform: rotate(90deg);\r\n        }\r\n         .swap-btn:hover {\r\n            transform: rotate(270deg);\r\n        }\r\n\r\n        .converter-controls .form-group {\r\n            width: 100%;\r\n        }\r\n    }\r\n<\/style>\r\n\r\n<div class=\"html-viewer-app\">\r\n    <div class=\"main-content\">\r\n        <div class=\"converter-container\">\r\n            <div class=\"section-header\">\r\n                Currency Converter\r\n            <\/div>\r\n            <div class=\"converter-body\">\r\n                <div class=\"form-group\">\r\n                    <label for=\"amount\">Amount<\/label>\r\n                    <input type=\"number\" id=\"amount\" class=\"currency-input\" value=\"100\" step=\"1\" min=\"0\">\r\n                <\/div>\r\n\r\n                <div class=\"converter-controls\">\r\n                    <div class=\"form-group\">\r\n                        <label for=\"fromCurrency\">From<\/label>\r\n                        <select id=\"fromCurrency\" class=\"currency-select\"><\/select>\r\n                    <\/div>\r\n\r\n                    <button id=\"swapBtn\" class=\"swap-btn\" aria-label=\"Swap currencies\">\r\n                        &#x21C6;\r\n                    <\/button>\r\n\r\n                    <div class=\"form-group\">\r\n                        <label for=\"toCurrency\">To<\/label>\r\n                        <select id=\"toCurrency\" class=\"currency-select\"><\/select>\r\n                    <\/div>\r\n                <\/div>\r\n\r\n                <div id=\"resultDisplay\" class=\"result-display\">\r\n                    Enter an amount to convert\r\n                <\/div>\r\n            <\/div>\r\n        <\/div>\r\n    <\/div>\r\n<\/div>\r\n\r\n<script>\r\n    document.addEventListener('DOMContentLoaded', () => {\r\n        const amountInput = document.getElementById('amount');\r\n        const fromCurrencySelect = document.getElementById('fromCurrency');\r\n        const toCurrencySelect = document.getElementById('toCurrency');\r\n        const swapBtn = document.getElementById('swapBtn');\r\n        const resultDisplay = document.getElementById('resultDisplay');\r\n\r\n        const API_URL = 'https:\/\/api.frankfurter.app';\r\n\r\n        \/\/ 1. Fetch currencies and populate dropdowns\r\n        async function populateCurrencies() {\r\n            try {\r\n                const response = await fetch(`${API_URL}\/currencies`);\r\n                if (!response.ok) throw new Error('Failed to load currency list.');\r\n                \r\n                const currencies = await response.json();\r\n                const fragment = document.createDocumentFragment();\r\n\r\n                for (const currencyCode in currencies) {\r\n                    const option = document.createElement('option');\r\n                    option.value = currencyCode;\r\n                    option.textContent = `${currencyCode} - ${currencies[currencyCode]}`;\r\n                    fragment.appendChild(option);\r\n                }\r\n\r\n                fromCurrencySelect.appendChild(fragment.cloneNode(true));\r\n                toCurrencySelect.appendChild(fragment);\r\n\r\n                \/\/ Set default values\r\n                fromCurrencySelect.value = 'USD';\r\n                toCurrencySelect.value = 'EUR';\r\n                \r\n                \/\/ Perform initial conversion\r\n                convertCurrency();\r\n\r\n            } catch (error) {\r\n                resultDisplay.textContent = `Error: ${error.message}`;\r\n            }\r\n        }\r\n\r\n        \/\/ 2. Perform the currency conversion\r\n        async function convertCurrency() {\r\n            const amount = parseFloat(amountInput.value);\r\n            const fromCurrency = fromCurrencySelect.value;\r\n            const toCurrency = toCurrencySelect.value;\r\n\r\n            if (isNaN(amount) || amount <= 0) {\r\n                resultDisplay.innerHTML = 'Please enter a valid amount';\r\n                return;\r\n            }\r\n            \r\n            if (!fromCurrency || !toCurrency) {\r\n                 resultDisplay.innerHTML = 'Loading currencies...';\r\n                return;\r\n            }\r\n\r\n            resultDisplay.innerHTML = 'Converting...';\r\n\r\n            if (fromCurrency === toCurrency) {\r\n                resultDisplay.innerHTML = `<div>${amount.toFixed(2)} ${toCurrency}<\/div>`;\r\n                return;\r\n            }\r\n\r\n            try {\r\n                const response = await fetch(`${API_URL}\/latest?amount=${amount}&from=${fromCurrency}&to=${toCurrency}`);\r\n                if (!response.ok) throw new Error('Conversion failed.');\r\n                \r\n                const data = await response.json();\r\n                const convertedAmount = data.rates[toCurrency];\r\n                const singleRate = (convertedAmount \/ amount).toFixed(4);\r\n\r\n                resultDisplay.innerHTML = `\r\n                    <div>${convertedAmount.toFixed(2)} ${toCurrency}<\/div>\r\n                    <span class=\"rate\">1 ${fromCurrency} = ${singleRate} ${toCurrency}<\/span>\r\n                `;\r\n\r\n            } catch (error) {\r\n                resultDisplay.textContent = `Error: ${error.message}`;\r\n            }\r\n        }\r\n\r\n        \/\/ 3. Swap the selected currencies\r\n        function swapCurrencies() {\r\n            const temp = fromCurrencySelect.value;\r\n            fromCurrencySelect.value = toCurrencySelect.value;\r\n            toCurrencySelect.value = temp;\r\n            convertCurrency();\r\n        }\r\n\r\n        \/\/ --- Event Listeners ---\r\n        amountInput.addEventListener('input', convertCurrency);\r\n        fromCurrencySelect.addEventListener('change', convertCurrency);\r\n        toCurrencySelect.addEventListener('change', convertCurrency);\r\n        swapBtn.addEventListener('click', swapCurrencies);\r\n\r\n        \/\/ Initial population of currencies\r\n        populateCurrencies();\r\n    });\r\n<\/script>\r\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[22],"tags":[21],"class_list":["post-8311099","post","type-post","status-publish","format-standard","hentry","category-tools","tag-html-css-tools"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Currency Converter<\/title>\n<meta name=\"description\" content=\"Easily convert currencies with our free, real-time Currency Converter. Get accurate exchange rates for all major global currencies for travel, shopping, and business.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/elementor.com\/tools\/currency-converter\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Currency Converter\" \/>\n<meta property=\"og:description\" content=\"Easily convert currencies with our free, real-time Currency Converter. Get accurate exchange rates for all major global currencies for travel, shopping, and business.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/elementor.com\/tools\/currency-converter\/\" \/>\n<meta property=\"og:site_name\" content=\"Tools\" \/>\n<meta property=\"article:published_time\" content=\"2025-09-18T07:29:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-18T07:35:33+00:00\" \/>\n<meta name=\"author\" content=\"liz@148.red\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"liz@148.red\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/elementor.com\/tools\/currency-converter\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/elementor.com\/tools\/currency-converter\/\"},\"author\":{\"name\":\"liz@148.red\",\"@id\":\"https:\/\/elementor.com\/tools\/#\/schema\/person\/80e8375cb95e6030bc2f897c41c985ac\"},\"headline\":\"Currency Converter\",\"datePublished\":\"2025-09-18T07:29:44+00:00\",\"dateModified\":\"2025-09-18T07:35:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/elementor.com\/tools\/currency-converter\/\"},\"wordCount\":4,\"keywords\":[\"Html-Css-tools\"],\"articleSection\":[\"tools\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/elementor.com\/tools\/currency-converter\/\",\"url\":\"https:\/\/elementor.com\/tools\/currency-converter\/\",\"name\":\"Currency Converter\",\"isPartOf\":{\"@id\":\"https:\/\/elementor.com\/tools\/#website\"},\"datePublished\":\"2025-09-18T07:29:44+00:00\",\"dateModified\":\"2025-09-18T07:35:33+00:00\",\"author\":{\"@id\":\"https:\/\/elementor.com\/tools\/#\/schema\/person\/80e8375cb95e6030bc2f897c41c985ac\"},\"description\":\"Easily convert currencies with our free, real-time Currency Converter. Get accurate exchange rates for all major global currencies for travel, shopping, and business.\",\"breadcrumb\":{\"@id\":\"https:\/\/elementor.com\/tools\/currency-converter\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/elementor.com\/tools\/currency-converter\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/elementor.com\/tools\/currency-converter\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/elementor.com\/tools\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Currency Converter\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/elementor.com\/tools\/#website\",\"url\":\"https:\/\/elementor.com\/tools\/\",\"name\":\"Tools\",\"description\":\"Just another Elementor hosted website ;)\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/elementor.com\/tools\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/elementor.com\/tools\/#\/schema\/person\/80e8375cb95e6030bc2f897c41c985ac\",\"name\":\"liz@148.red\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/63b900d3310bd1ed40162fb27f016e9920ae66fa5be07be5153344329ef7d9d2?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/63b900d3310bd1ed40162fb27f016e9920ae66fa5be07be5153344329ef7d9d2?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/63b900d3310bd1ed40162fb27f016e9920ae66fa5be07be5153344329ef7d9d2?s=96&d=mm&r=g\",\"caption\":\"liz@148.red\"},\"url\":\"https:\/\/elementor.com\/tools\/author\/liz148-red\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Currency Converter","description":"Easily convert currencies with our free, real-time Currency Converter. Get accurate exchange rates for all major global currencies for travel, shopping, and business.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/elementor.com\/tools\/currency-converter\/","og_locale":"en_US","og_type":"article","og_title":"Currency Converter","og_description":"Easily convert currencies with our free, real-time Currency Converter. Get accurate exchange rates for all major global currencies for travel, shopping, and business.","og_url":"https:\/\/elementor.com\/tools\/currency-converter\/","og_site_name":"Tools","article_published_time":"2025-09-18T07:29:44+00:00","article_modified_time":"2025-09-18T07:35:33+00:00","author":"liz@148.red","twitter_card":"summary_large_image","twitter_misc":{"Written by":"liz@148.red","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/elementor.com\/tools\/currency-converter\/#article","isPartOf":{"@id":"https:\/\/elementor.com\/tools\/currency-converter\/"},"author":{"name":"liz@148.red","@id":"https:\/\/elementor.com\/tools\/#\/schema\/person\/80e8375cb95e6030bc2f897c41c985ac"},"headline":"Currency Converter","datePublished":"2025-09-18T07:29:44+00:00","dateModified":"2025-09-18T07:35:33+00:00","mainEntityOfPage":{"@id":"https:\/\/elementor.com\/tools\/currency-converter\/"},"wordCount":4,"keywords":["Html-Css-tools"],"articleSection":["tools"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/elementor.com\/tools\/currency-converter\/","url":"https:\/\/elementor.com\/tools\/currency-converter\/","name":"Currency Converter","isPartOf":{"@id":"https:\/\/elementor.com\/tools\/#website"},"datePublished":"2025-09-18T07:29:44+00:00","dateModified":"2025-09-18T07:35:33+00:00","author":{"@id":"https:\/\/elementor.com\/tools\/#\/schema\/person\/80e8375cb95e6030bc2f897c41c985ac"},"description":"Easily convert currencies with our free, real-time Currency Converter. Get accurate exchange rates for all major global currencies for travel, shopping, and business.","breadcrumb":{"@id":"https:\/\/elementor.com\/tools\/currency-converter\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/elementor.com\/tools\/currency-converter\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/elementor.com\/tools\/currency-converter\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/elementor.com\/tools\/"},{"@type":"ListItem","position":2,"name":"Currency Converter"}]},{"@type":"WebSite","@id":"https:\/\/elementor.com\/tools\/#website","url":"https:\/\/elementor.com\/tools\/","name":"Tools","description":"Just another Elementor hosted website ;)","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/elementor.com\/tools\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/elementor.com\/tools\/#\/schema\/person\/80e8375cb95e6030bc2f897c41c985ac","name":"liz@148.red","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/63b900d3310bd1ed40162fb27f016e9920ae66fa5be07be5153344329ef7d9d2?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/63b900d3310bd1ed40162fb27f016e9920ae66fa5be07be5153344329ef7d9d2?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/63b900d3310bd1ed40162fb27f016e9920ae66fa5be07be5153344329ef7d9d2?s=96&d=mm&r=g","caption":"liz@148.red"},"url":"https:\/\/elementor.com\/tools\/author\/liz148-red\/"}]}},"_links":{"self":[{"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/posts\/8311099","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/comments?post=8311099"}],"version-history":[{"count":3,"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/posts\/8311099\/revisions"}],"predecessor-version":[{"id":8311104,"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/posts\/8311099\/revisions\/8311104"}],"wp:attachment":[{"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/media?parent=8311099"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/categories?post=8311099"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/tags?post=8311099"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}