One file on GitHub, five addresses, and how to move between them
GitHub gives the same file several addresses, and each one does a different job. Take a file at github.com/vitejs/vite/blob/main/packages/vite/package.json. That address opens a web page with the file inside it, line numbers, a history button and the rest of GitHub around it. It is the right link to send a person. It is the wrong link to give curl, because curl would download the HTML of that page and not the file.
For a script you want the raw address: raw.githubusercontent.com/vitejs/vite/main/packages/vite/package.json. It has a different host and no /blob segment, and it returns only the file's bytes. Paste the first address into this tool and the Raw file row shows exactly that. It works the other way too. Paste a raw address that a build log printed, and the File on GitHub row gives you the page a person can read.
Line ranges travel with the file view. Add #L10-L20 to a file address and GitHub highlights lines 10 to 20 when it opens. The tool reads that fragment, shows the range, and keeps it on the file view link it builds. It drops it from the raw link, because a raw file has no page to highlight. The same parts also give the clone addresses. https://github.com/vitejs/vite.git works anywhere, and git@github.com:vitejs/vite.git works when you have an SSH key on your account. The ZIP address, github.com/vitejs/vite/archive/main.zip, downloads the files at that branch without any git history.
One part of a GitHub address cannot be read with certainty. Branch names may contain slashes, so /blob/release/2.0/README.md could mean the branch release and the file 2.0/README.md, or the branch release/2.0 and the file README.md. Both are valid, and GitHub decides by checking which branches exist. This tool cannot check, because it never contacts GitHub. It takes the first segment as the branch, like most scripts do, and puts a note beside the branch when a path follows it. If your branches use slashes, fix the split by eye.
The other limits are simple. The tool reads github.com addresses and SSH clone addresses. It does not read GitHub Enterprise hosts, Gists or other code hosts such as GitLab. It does not check that the repository, branch or file exists, so an address with a typo produces neat links to nothing. Everything happens on this page, so you can use it on addresses from private repositories without telling anyone which ones they are.