30 Useful Coding Tools for Developers
1. File Converter (Python)
import os
from PIL import Image
def convert_image(input_path, output_format):
img = Image.open(input_path)
output_path = os.path.splitext(input_path)[0] + f'.{output_format}'
img.save(output_path)
print(f"Converted to {output_format} successfully!")
2. Password Generator (Python)
import random
import string
def generate_password(length=12):
chars = string.ascii_letters + string.digits + string.punctuation
return ''.join(random.choice(chars) for _ in range(length))
3. URL Shortener (JavaScript)
const urlDatabase = {};
function shortenURL(longURL) {
const shortCode = Math.random().toString(36).substring(2, 8);
urlDatabase[shortCode] = longURL;
return `short.url/${shortCode}`;
}
4. QR Code Generator (Python)
import qrcode
def generate_qr(data, filename="qrcode.png"):
img = qrcode.make(data)
img.save(filename)
print(f"QR code saved as {filename}")
5. Currency Converter (Python)
import requests
def convert_currency(amount, from_curr, to_curr):
url = f"https://api.exchangerate-api.com/v4/latest/{from_curr}"
response = requests.get(url).json()
rate = response['rates'][to_curr]
return amount * rate
6. Text to Speech (Python)
from gtts import gTTS
import os
def text_to_speech(text, lang='en'):
tts = gTTS(text=text, lang=lang)
tts.save("output.mp3")
os.system("start output.mp3")
7. File Encryption (Python)
from cryptography.fernet import Fernet
def encrypt_file(filename, key):
fernet = Fernet(key)
with open(filename, 'rb') as file:
original = file.read()
encrypted = fernet.encrypt(original)
with open(filename + ".enc", 'wb') as encrypted_file:
encrypted_file.write(encrypted)
8. Web Scraper (Python)
import requests
from bs4 import BeautifulSoup
def scrape_website(url):
page = requests.get(url)
soup = BeautifulSoup(page.content, 'html.parser')
return soup.get_text()
9. Temperature Converter (JavaScript)
function celsiusToFahrenheit(celsius) {
return (celsius * 9/5) + 32;
}
function fahrenheitToCelsius(fahrenheit) {
return (fahrenheit - 32) * 5/9;
}
10. Markdown to HTML Converter (Python)
import markdown
def md_to_html(md_text):
return markdown.markdown(md_text)
11. Image Resizer (Python)
from PIL import Image
def resize_image(input_path, output_path, size):
with Image.open(input_path) as img:
img.thumbnail(size)
img.save(output_path)
12. JSON Validator (JavaScript)
function isValidJSON(jsonString) {
try {
JSON.parse(jsonString);
return true;
} catch (e) {
return false;
}
}
13. CSV to JSON Converter (Python)
import csv
import json
def csv_to_json(csv_file, json_file):
data = []
with open(csv_file) as csvf:
csv_reader = csv.DictReader(csvf)
for row in csv_reader:
data.append(row)
with open(json_file, 'w') as jsonf:
jsonf.write(json.dumps(data, indent=4))
14. Random Quote Generator (JavaScript)
const quotes = [
"The only way to do great work is to love what you do. - Steve Jobs",
"Innovation distinguishes between a leader and a follower. - Steve Jobs",
"Stay hungry, stay foolish. - Steve Jobs"
];
function getRandomQuote() {
return quotes[Math.floor(Math.random() * quotes.length)];
}
15. BMI Calculator (Python)
def calculate_bmi(weight, height):
bmi = weight / (height ** 2)
if bmi < 18.5:
category = "Underweight"
elif 18.5 <= bmi < 25:
category = "Normal weight"
elif 25 <= bmi < 30:
category = "Overweight"
else:
category = "Obese"
return bmi, category
16. Age Calculator (JavaScript)
function calculateAge(birthDate) {
const today = new Date();
const birth = new Date(birthDate);
let age = today.getFullYear() - birth.getFullYear();
const monthDiff = today.getMonth() - birth.getMonth();
if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birth.getDate())) {
age--;
}
return age;
}
17. File Search Tool (Python)
import os
def search_files(directory, extension):
matches = []
for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith(extension):
matches.append(os.path.join(root, file))
return matches
18. Palindrome Checker (JavaScript)
function isPalindrome(str) {
const cleaned = str.toLowerCase().replace(/[^a-z0-9]/g, '');
return cleaned === cleaned.split('').reverse().join('');
}
19. Email Validator (Python)
import re
def is_valid_email(email):
pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
return re.match(pattern, email) is not None
20. Word Counter (Python)
def count_words(text):
words = text.split()
return len(words)
21. Time Zone Converter (Python)
from datetime import datetime
import pytz
def convert_timezone(dt, from_tz, to_tz):
from_zone = pytz.timezone(from_tz)
to_zone = pytz.timezone(to_tz)
dt = from_zone.localize(dt)
return dt.astimezone(to_zone)
22. IP Address Lookup (Python)
import socket
def get_ip_info(domain):
try:
ip = socket.gethostbyname(domain)
return {"domain": domain, "ip": ip}
except socket.gaierror:
return None
23. File Checksum Generator (Python)
import hashlib
def get_file_checksum(filename, algorithm='sha256'):
h = hashlib.new(algorithm)
with open(filename, 'rb') as file:
while chunk := file.read(4096):
h.update(chunk)
return h.hexdigest()
24. Base64 Encoder/Decoder (JavaScript)
function encodeBase64(text) {
return btoa(text);
}
function decodeBase64(encoded) {
return atob(encoded);
}
25. Directory Size Calculator (Python)
import os
def get_directory_size(directory):
total = 0
for entry in os.scandir(directory):
if entry.is_file():
total += entry.stat().st_size
elif entry.is_dir():
total += get_directory_size(entry.path)
return total
26. Roman Numeral Converter (Python)
def int_to_roman(num):
val = [
1000, 900, 500, 400,
100, 90, 50, 40,
10, 9, 5, 4,
1
]
syb = [
"M", "CM", "D", "CD",
"C", "XC", "L", "XL",
"X", "IX", "V", "IV",
"I"
]
roman_num = ''
i = 0
while num > 0:
for _ in range(num // val[i]):
roman_num += syb[i]
num -= val[i]
i += 1
return roman_num
27. Color Code Converter (JavaScript)
function rgbToHex(r, g, b) {
return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
}
function hexToRgb(hex) {
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
}
28. PDF Merger (Python)
from PyPDF2 import PdfMerger
def merge_pdfs(pdf_list, output):
merger = PdfMerger()
for pdf in pdf_list:
merger.append(pdf)
merger.write(output)
merger.close()
29. HTTP Server (Python)
from http.server import SimpleHTTPRequestHandler, HTTPServer
def run_server(port=8000):
server_address = ('', port)
httpd = HTTPServer(server_address, SimpleHTTPRequestHandler)
print(f"Serving on port {port}...")
httpd.serve_forever()
30. Video to Audio Converter (Python)
from moviepy.editor import VideoFileClip
def extract_audio(video_path, audio_path):
video = VideoFileClip(video_path)
audio = video.audio
audio.write_audiofile(audio_path)
audio.close()
video.close()
Pro Tip: For better SEO, consider adding a description before each tool explaining its purpose and use cases. Also, add relevant keywords naturally throughout your post.