👉 Access the LanguageTool source code and related assets directly on their GitHub repository.
Example:
<!DOCTYPE html> <html> <head> <title>Grammar Check example using JavaScript</title> </head> <body> <h1>Grammar Check example using JavaScript</h1> <div> <textarea id="t1" placeholder="Type or paste your text here..."></textarea> </div> <button onclick="grammarCheck(document.getElementById('t1').value)">Check Grammar</button> <div id="grammarResults"></div> </body> <script> async function grammarCheck(text) { const url = "https://api.languagetool.org/v2/check"; // The url of the api. const params = new URLSearchParams({ text: text, language: "en" // It also has option for differenct languages. Change the language as per your requirement. }); try { const response = await fetch(url, { method: "POST", body: params }); const data = await response.json(); const resultDiv = document.getElementById("grammarResults"); resultDiv.innerHTML = ""; // Clear previous results. if (data.matches.length > 0) { data.matches.forEach(match => { const issue = document.createElement("p"); issue.innerHTML = `<strong>Error:</strong> ${match.message} <br> <strong>Suggestion:</strong> ${match.replacements.map(r => r.value).join(", ")}`; resultDiv.appendChild(issue); }); } else { resultDiv.innerHTML = "<p>No grammar issues found!</p>"; } } catch (error) { console.error("Error checking grammar:", error); } } </script> </html>
The Word Counter - Count Words and Characters:
The Word Counter is an intuitive, online tool that helps you count words, characters, and analyze word frequency. Simply start typing in the text area or paste your content, and the tool will automatically provide accurate counts and analysis.
Try our Word Counter Tool
The function grammarCheck(text) sends the provided text to the LanguageTool API for grammar analysis. It retrieves grammar errors (if any) and their suggested corrections. Finally, the result is displayed.
LanguageTool API
👉 The api.languagetool.org offers a free version of its API, but it comes with limitations. I have used the free version in the above example. The free tier allows 20 requests per minute per IP and a maximum of 20,000 characters per request. If you need higher limits, they offer premium plans.
LanguageTool is an AI-powered grammar and style checker that helps users improve their writing across multiple languages. It offers features like grammar correction, spelling checks, punctuation fixes, style improvements, and even paraphrasing. LanguageTool integrates seamlessly with popular platforms like Google Docs, Microsoft Word, and web browsers, making it accessible for various writing needs.
✅ Pros
1) Multi-Language Support: It supports over 30 languages, making it ideal for multilingual users.
2) Ease of Use: The browser add-ons and integrations with office programs ensure a smooth user experience.
3) Advanced Features: Includes tools for paraphrasing, style suggestions, and even tracking productivity.
4) Privacy-Friendly: Texts are not stored when using the browser add-on.
5) Free Version: Offers a free tier with basic grammar and spelling checks.
❌ Cons
1) Limited Free Tier: The free version has restrictions, such as fewer advanced suggestions and limited paraphrasing.
2) Premium Cost: Advanced features like unlimited paraphrasing and picky mode require a paid subscription.
3) Accuracy: While effective, it may occasionally miss nuanced errors or context-specific corrections.
🤔 A small observation: The free version does not highlight the specific words or errors it detects. For instance, if there is an extra space after the name 'Arun Banik,' it simply points out the error without marking it. This limitation can make identifying errors challenging, especially in lengthy paragraphs.