The Senate Judiciary Committee has nearly completed rewriting the nation's federal criminal laws, a project of enormous proportions that, among other things, would severely restrict the broad discretionary powers given judges in passing sentence on criminals.

If passed, the legislation would be the first consolidation of laws that Congress has scattered through the statute books in 200 years of legislative activity.

At the least, the new code would simplify a confusing jumble of statutes that has confounded federal judges for years, and reduce a chaotic state of archiac - and often contradictory - legal definitions to a streamlined and understandable package.

Attorney General Griffin B. Bell, whose intense interest in the measure has moved him to attend markup sessions of the committee, likens the federal criminal laws to the attic of a 200-year-old house.

"A great many things are stored there which once may have served useful purposes," he said. "When they were no longer needed, they were not discarded but were left instead to gather dust."

Included in the current criminal code are laws prohibiting the detaining of government carrier pigeons and punishing seamen who seduce female passengers aboard steamships.

More importantly, however, the new code would impose new restrictions on what the bill's co-sponsor, Sen. Edward M. Kennedy (D-Mass), calls "a national scandal" - the disparate range of penalties that seem at each extreme to bear little relationship to the crime.

A bank robber, for example, now may receive anything from release on probation to 25 years in prison, depending on the inclination of the sentencing judge. A rapist may walk from the courtroom with a suspended sentence, or go to prison for the rest of his life.

From a more cosmic perspective, the new code even calls into question the concept of institutional rehabilitation, under which prisons in America have functioned since the turn-of-the-century reform movement.

The bill, unless amended, would mandate a new Federal Sentencing Commission that would write sentencing guidelines for various crimes as nearly fixed as possible.

Federal judges would be expected to follow these guidelines, and the maximum term under any guideline could not exceed the minimum by more than 25 per cent.

Moreover, if a judge imposed a sentence higher than the guidelines, he would have to justify it in writing, and the prisoner could appeal. If an offender is sentenced below the guideline, the government could appeal.

The federal parole system, which has come under increasing attack as arbitrary and ineffective, would be drastically scaled down. Parole eligibility would be eliminated unless specifically requested by the sentencing judge.

While not altogether dismissing the roler of rehabilitation in prisons, the bill seems to subjugate it to other sentencing purposes - deterrence, protection of the public and punishment of the criminal.

Since criminal law in the United States is largely a state rather than a federal responsibility, the vast majority of law enforcement would not be affected by the new code.

But the bill's supporters point out that traditionally state legislatures have followed the lead of federal statutes, and the proposed code is regarded as a bellwether for provincial revisions.

While arguing against the bill's liberalization of marijuana laws, committee member Sen. Orrin G. Hatch (R-Utah) last weeek declared, "I don't want it to go across the country that we are doing this . . . What concerns me is the symbolism of the situation." Sen. Birch Bayh (D-Ind.), defending the marijuana law changes, conceded that whatever the committee did would be a "signal" to states to follow suit.

The bill - S.1437 - is the product of 10 years of bitter dispute between Senate liberals and conservatives, and is a successor to the extremely controversial S.1 criminal code bill that evolved from the 1966 National Commission on Reform of Federal Criminal Laws, chaired by former California Gov. Edmund G. (Pat) Brown.

Liberal critics, led by the American Civil Liberties Union and the National Committee Against Repressive Legislation (NCARL), labeled S.1 a "blueprint for a police state," warning that its provisions on espionage and sabotage were so broad that it would, among other things, create a National Secrets Act and outlaw any public demonstration, no matter how orderly.

S.1 eventually became hopelessly mired in committee and died there.

The new measure, dubbed "Son of S.1" by the still critical liberal organizations, has deleted or modified many of the old bill's most controversial features, including expansion of the death penalty, abolition of insanity as a defense in federal criminal trials and new categories of crimes in the publishing of government secrets.

But the ACLU and NCARL, a Los Angeles-based group, have been lobbying intensely against the new bill, presenting rafts of suggested amendments to liberal members of the committee, including Sens. Bayh, James Abourezk (D-S.D.), Joseph R. Biden Jr. (D-Del.), Howard M. Metzenbaum (D-Ohio), Dennis DeConcini (D-Ariz.), Charles McC. Mathias Jr. (R-Md.) and John C. Culver (D-Iowa).

Some of the amendments have been approved by the 17-member committee and some have been rejected. The result has been to jeopardize a fragile compromise worked out between Kennedy, representing the liberal viewpoint, and John L. McClellan (D-Ark.), representing the conservatives on the committee.

Some committee aides have even suggested that the delicate compromise could collapse and and entire bill could fail in committee as a result of the amendments.

The amendments that have passed include: decriminalization of the use of small amounts of marijuana (which may not stand up to re-balloting), a restriction on judges who jail reporters violating "gag" orders, the 25 per cent differential between minimum and maximum prison sentences, and a 30-day limit on the time authorities can take to determine whether a person charged with a crime is mentally competent to stand trial.

Although about 95 per cent of the 360-page bill has been approved by committee - much of it in blocks by unanimous vote - about two dozen major and controversial amendments remain to be argued this week when deliberations resume.

They include the liberals' suggestion to reduce the number of crimes in which wiretaps can be used, a proposal the Justice Department firmly opposes, and the conservatives' suggestion to expand the death penalty to certain crimes of treason and murder.

Also due for heated debate is an amendment that would substitute "transactional" immunity for "use" immunity in the taking of testimony by witnesses.

The difference is that transactional immunity compels a witness to testify about offenses committed by others, but precludes future prosecution for any crime of his own he touches upon in his testimony. Critics call it an "immunity bath" and claim witnesses could mention their involvement in a crime just to gain immunity, and then profess to have forgotten details involving others.

Use immunity, which is now used, also compels testimony but allows the government to prosecute, offering protection only from the government's use of the information divulged.

Critics of the current immunity system say it doesn't afford the witness enough protection, while defenders claim use immunity provides an incentive to tell more about an offense - the more a witness reveals, the less the government can use against him.

The bill, in its present form, contains hundreds of other revisions of the federal criminal code, some of which are interpreted as civil liberties infringements by liberals and as "coddling" criminals by conservatives. Some sections are supported by spokesmen for both ideologies.

Some of the proposed measures are:

A number of new laws attacking white-collar crimes and a provision to broaden the law dealing with organized crime to include mobster investments in legitimate businesses.

The reduction of some 70 theft laws, 80 forgery and counterfeit statutes and 50 false-statement crimes into one comprehensive theft law and three perjury sections.

Repeal of the Logan Act, which prohibits private communication with a foreign government with intent to influence foreign policy. Sponsor point out that peace activists who communicated with the North Vietnamese government could have been prosecuted under the act.

Expansion of the Civil Rights Act of 1968 to prohibit discrimination based on sex as well as color or national origin.

Modernization of rape prosecution with corroboration of the victim's testimony no longer required. Impediments are offered to defense challenges to the victim's moral character.

Prohibitions of sabotaging political campaigns and other safeguards against "dirty tricks" in elections.

Possible compensation for victims of crimes by a federal compensation board. Payments of up to $50,000 for losses would be awarded to a victim or surviving dependent.

Consolidation and expansion of extradition statutes, making it easier for the government to try offenders arrested in separate jurisdictions.

A major increase in the maximum monetary fines that can be imposed including a provision that the fine can be double the amount of loss to the victim.

The committee will take up these and other proposals this week as it attempts to eliminate what Kennedy calls "a code that looks more like a Tower of Babel than a comprehensible criminal code."

The proposed revisions are not expected to reach the Senate floor until next year, and House action on a companion measure is just beginning, with opposition expected in the House Judiciary Committee.

But committee members insist that the differences may be less ideological than appearances indicate, and that passage in 1978 is possible.