PNG to SVG Converter – Free Online Tool
PNG to SVG Converter
Convert your PNG images to SVG vector format instantly – 100% free and secure
Selected Files (0)
🔒
100% Secure
All conversions happen in your browser. Files never leave your device.
âš¡
Vector Quality
Advanced image tracing creates high-quality scalable vector graphics.
📱
Works Everywhere
Fully responsive design works on desktop, tablet, and mobile devices.
`);
}
// Download single file
function downloadSingle(index) {
const file = convertedFiles[index];
const link = document.createElement('a');
link.href = file.url;
link.download = file.name;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
showNotification(`${file.name} downloaded`, 'success');
}
// Download all files as ZIP
async function downloadAll() {
if (convertedFiles.length === 0) return;
showNotification('Creating ZIP file...', 'info');
try {
const zip = new JSZip();
// Add all converted files to ZIP
convertedFiles.forEach(file => {
zip.file(file.name, file.blob);
});
// Generate ZIP
const zipBlob = await zip.generateAsync({ type: 'blob' });
// Download ZIP
const link = document.createElement('a');
link.href = URL.createObjectURL(zipBlob);
link.download = `converted-svg-${Date.now()}.zip`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
showNotification('ZIP file downloaded successfully!', 'success');
} catch (error) {
console.error('ZIP creation error:', error);
showNotification('Error creating ZIP file', 'error');
}
}
// Reset converter
function resetConverter() {
// Clear URLs to free memory
convertedFiles.forEach(file => URL.revokeObjectURL(file.url));
selectedFiles = [];
convertedFiles = [];
fileInput.value = '';
// Reset UI
selectedFilesSection.classList.add('hidden');
convertSection.classList.add('hidden');
progressSection.classList.add('hidden');
resultsSection.classList.add('hidden');
progressBar.style.width = '0%';
progressText.textContent = '0%';
showNotification('Ready for new conversion', 'info');
}
// Utility: Format file size
function formatFileSize(bytes) {
if (bytes === 0) return '0 Bytes';
const k = 1024;
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return Math.round(bytes / Math.pow(k, i) * 100) / 100 + ' ' + sizes[i];
}
// Notification system
function showNotification(message, type = 'info') {
const notification = document.getElementById('notification');
const content = document.getElementById('notificationContent');
const messageEl = document.getElementById('notificationMessage');
messageEl.textContent = message;
// Set border color based on type
const colors = {
success: 'border-green-500',
error: 'border-red-500',
info: 'border-blue-500'
};
content.className = `bg-white rounded-lg shadow-lg p-4 max-w-sm border-l-4 ${colors[type] || colors.info}`;
notification.classList.remove('hidden');
// Auto-hide after 4 seconds
setTimeout(hideNotification, 4000);
}
function hideNotification() {
document.getElementById('notification').classList.add('hidden');
}
// Clean up on page unload
window.addEventListener('beforeunload', () => {
convertedFiles.forEach(file => URL.revokeObjectURL(file.url));
});