SunCalc is a tiny dependency-free JavaScript library for calculating solar and lunar information for any location and time. It provides sun altitude and azimuth together with sunrise, sunset, twilight, and other sunlight phases. Moon calculations include position, rise and set times, distance, and illuminated phase. Version 2 rebuilt the astronomy around higher-order models from Jean Meeus and validates results against authoritative astronomical references. Typical rise and set errors are around 15 seconds, with substantially improved positional accuracy over the earlier release. It ships as a modern ES module while retaining bundled support for CommonJS and direct browser use.

Features

  • Sun position calculations
  • Sunrise, sunset, and twilight times
  • Moon position and distance
  • Moonrise, moonset, and lunar phase
  • High-precision astronomical models
  • ES module, CommonJS, and browser support

Project Samples

Project Activity

See All Activity >

Categories

Libraries

License

BSD License

Follow SunCalc

SunCalc Web Site

Other Useful Business Software
Custom VMs From 1 to 96 vCPUs With 99.95% Uptime Icon
Custom VMs From 1 to 96 vCPUs With 99.95% Uptime

General-purpose, compute-optimized, or GPU/TPU-accelerated. Built to your exact specs.

Live migration and automatic failover keep workloads online through maintenance. One free e2-micro VM every month.
Start Free
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of SunCalc!

Additional Project Details

Programming Language

JavaScript

Related Categories

JavaScript Libraries

Registered

2026-10-14