Which branch can declare legislation unconstitutional?
The Judicial Branch. Sometimes, the President as Chief Executive
will "declare" a law "unconstitutional"; however, this is a
political distinction, and if a true executive refusal to execute
or enforce were apprehended by the Court, a writ of mandamus
could issue, ordering the execution or enforcement of a law.
Similarly, as bills proceed through committee consideration in
the House and Senate, the Congressional Research Service is
sometimes used to research whether or not a particular provision
would likely be deemed unconstitutional, although this need not and
does not function as a bar to Congress enacting legislation parts
of which or the entirety of which are later found unconstitutional
by the Court.